Skip to content

Commit a8d9df5

Browse files
committed
rowexec: manually flush progress when backfiling vector indexes
Previously, the vector index codepath in backfill took no special action to update progress tracking. Since progress tracking uses BulkAdder flushes to determine when to flush progress and vector indexes don't currently use BulkAdders during backfill, this meant that vector index build status never got updated. This patch adds a manual flush of status whenever an IndexBatch containing a vector index completes. Vector index inserts are pretty slow and IndexBatches are pretty large, so this is unlikely to lead to too many flushes. Fixes: #146691 Release note (bug fix): Vector index backfill will now properly track job progress in SHOW JOBS output.
1 parent 83c038f commit a8d9df5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/sql/rowexec/indexbackfiller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func (ib *indexBackfiller) ingestIndexEntries(
342342

343343
var vectorInputEntry rowenc.IndexEntry
344344
for indexBatch := range indexEntryCh {
345+
addedToVectorIndex := false
345346
for _, indexEntry := range indexBatch.indexEntries {
346347
// Pace the admission control before processing each index entry.
347348
if err := pacer.Pace(ctx); err != nil {
@@ -359,6 +360,7 @@ func (ib *indexBackfiller) ingestIndexEntries(
359360
if err != nil {
360361
return ib.wrapDupError(ctx, err)
361362
} else if isVectorIndex {
363+
addedToVectorIndex = true
362364
continue
363365
}
364366
}
@@ -374,6 +376,12 @@ func (ib *indexBackfiller) ingestIndexEntries(
374376
mu.Lock()
375377
mu.addedSpans = append(mu.addedSpans, indexBatch.completedSpan)
376378
mu.Unlock()
379+
// Vector indexes don't add to the bulk adder and take a long time to add
380+
// entries, so flush progress manually after every indexBatch is processed
381+
// that contained vector index entries.
382+
if addedToVectorIndex {
383+
flushAddedSpans(kvpb.BulkOpSummary{})
384+
}
377385

378386
// After the index KVs have been copied to the underlying BulkAdder, we can
379387
// free the memory which was accounted when building the index entries of the
@@ -404,14 +412,6 @@ func (ib *indexBackfiller) ingestIndexEntries(
404412
if err := g.Wait(); err != nil {
405413
return err
406414
}
407-
408-
// If there are only vector indexes, we push the completed spans manually so that
409-
// progress reporting works.
410-
// TODO(mw5h): this is a hack to get progress reporting to work for vector only
411-
// backfills. We should remove this once we have a more permanent solution.
412-
if ib.VectorOnly {
413-
flushAddedSpans(kvpb.BulkOpSummary{})
414-
}
415415
if err := adder.Flush(ctx); err != nil {
416416
return ib.wrapDupError(ctx, err)
417417
}

0 commit comments

Comments
 (0)