Skip to content

Commit 100ff29

Browse files
authored
fix(core): fix table suspension due to indexing error (#5984)
1 parent f1b1196 commit 100ff29

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

core/src/main/java/io/questdb/cairo/O3OpenColumnJob.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,18 @@ public static void openColumn(
15281528
srcDataOldPartitionSize,
15291529
o3SplitPartitionSize,
15301530
tableWriter,
1531-
indexWriter,
1531+
// Even though we are not using mapped memory for the last partition from the table writer
1532+
// we must use its indexers to produce consistent index results. The condition here is
1533+
// "creative" - we want to avoid bitmap index lookup for each and every column. We will use
1534+
// presence of "indexWriter" as the guide. For columns that do not need indexing, this
1535+
// writer would be null.
1536+
1537+
// Consistent use of tableWriter's indexer is required because last partition could be updated
1538+
// from two places, this is one of them. The other also uses tableWriter's index and is more
1539+
// straightforward. Failure to make them consistent manifests when this site updates index and
1540+
// extends its value memory, it may do so without extending key memory. Then key memory has
1541+
// the reference to a value block, which would be outside the mapped area for tableWriters' indexer.
1542+
openColumnMode == OPEN_LAST_PARTITION_FOR_APPEND && indexWriter != null ? tableWriter.getBitmapIndexWriter(columnIndex) : indexWriter,
15321543
colTopSinkAddr,
15331544
columnIndex,
15341545
columnNameTxn,

core/src/main/java/io/questdb/cairo/O3PartitionJob.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -296,24 +296,6 @@ public static void processParquetPartition(
296296
LOG.error().$("could not truncate partition file [path=").$(path).I$();
297297
}
298298
ff.close(fd);
299-
// delete all index files unconditionally
300-
path.of(pathToTable);
301-
setPathForNativePartition(path, partitionBy, partitionTimestamp, srcNameTxn);
302-
final int pLen = path.size();
303-
for (int i = 0, n = tableWriterMetadata.getColumnCount(); i < n; i++) {
304-
if (tableWriterMetadata.getColumnType(i) == ColumnType.SYMBOL && tableWriterMetadata.isColumnIndexed(i)) {
305-
final CharSequence columnName = tableWriterMetadata.getColumnName(i);
306-
final long columnNameTxn = tableWriter.getColumnNameTxn(partitionTimestamp, i);
307-
final int indexBlockCapacity = tableWriterMetadata.getIndexValueBlockCapacity(i);
308-
if (indexBlockCapacity < 0) {
309-
continue;
310-
}
311-
312-
BitmapIndexUtils.keyFileName(path.trimTo(pLen), columnName, columnNameTxn);
313-
BitmapIndexUtils.valueFileName(path.trimTo(pLen), columnName, columnNameTxn);
314-
}
315-
}
316-
317299
tableWriter.o3BumpErrorCount(CairoException.isCairoOomError(th));
318300
} finally {
319301
path.of(pathToTable);

0 commit comments

Comments
 (0)