Skip to content

Commit

Permalink
backfill: finish the tracing span after closing the account
Browse files Browse the repository at this point in the history
We recently fixed an issue where we forgot to stop the index backfill
merger monitor, but we had a minor bug in that fix - we captured the
context that contains the tracing span that is finished before the
account is closed leading to "use after finish" assertions. This is now
fixed.

Release note: None
  • Loading branch information
yuzefovich committed Mar 12, 2024
1 parent 38880d9 commit 5ae5417
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/backfill/mvcc_index_merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const indexBackfillMergeProgressReportInterval = 10 * time.Second

// Run runs the processor.
func (ibm *IndexBackfillMerger) Run(ctx context.Context, output execinfra.RowReceiver) {
opName := "IndexBackfillMerger"
ctx = logtags.AddTag(ctx, opName, int(ibm.spec.Table.ID))
ctx, span := execinfra.ProcessorSpan(ctx, ibm.flowCtx, opName, ibm.processorID)
defer span.Finish()
// This method blocks until all worker goroutines exit, so it's safe to
// close memory monitoring infra in defers.
mergerMon := execinfra.NewMonitor(ctx, ibm.flowCtx.Cfg.BackfillerMonitor, "index-backfiller-merger-mon")
Expand All @@ -113,10 +117,6 @@ func (ibm *IndexBackfillMerger) Run(ctx context.Context, output execinfra.RowRec
defer ibm.muBoundAccount.Unlock()
ibm.muBoundAccount.boundAccount.Close(ctx)
}()
opName := "IndexBackfillMerger"
ctx = logtags.AddTag(ctx, opName, int(ibm.spec.Table.ID))
ctx, span := execinfra.ProcessorSpan(ctx, ibm.flowCtx, opName, ibm.processorID)
defer span.Finish()
defer output.ProducerDone()
defer execinfra.SendTraceData(ctx, ibm.flowCtx, output)

Expand Down

0 comments on commit 5ae5417

Please sign in to comment.