Skip to content

Commit 6858087

Browse files
committed
colcontainer: harden ctx capture in diskQueueWriter
In ffb4666 we added more memory accounting to the disk queue. This required capturing the context inside the `diskQueueWriter` in order to preserve the `io.Writer` signature. We just saw a test failure where this capture was problematic - it's possible that when we close the disk queue as a whole (which happens _after_ closing all operators) that the captured context contains the tracing span that has been finished (since the relevant operator has already been closed). To go around this issue we now update the captured context before finishing each file. An alternative solution could've been to use `context.Background` since we only need the context object for memory accounting purposes (in a single `Resize` call) so losing some contextual information there doesn't seem like a big deal. Release note: None
1 parent 0c9c77f commit 6858087

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/sql/colcontainer/diskqueue.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,12 @@ func (d *diskQueue) writeFooterAndFlush(ctx context.Context) (err error) {
597597
d.serializer = nil
598598
}
599599
}()
600+
if d.writer != nil {
601+
// The context that we captured when we created the diskQueueWriter
602+
// might have a tracing span that has already been finished. To go
603+
// around this, we capture the fresh context.
604+
d.writer.ctx = ctx
605+
}
600606
if err := d.serializer.Finish(); err != nil {
601607
return err
602608
}

0 commit comments

Comments
 (0)