Skip to content

Commit dd67cb8

Browse files
authored
Merge pull request #154261 from cockroachdb/blathers/backport-release-25.4-154209
release-25.4: rowexec: manually flush progress when backfiling vector indexes
2 parents ffd525b + 4ad7993 commit dd67cb8

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)