Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colexec: fix span use after finish in edge cases in parallel sync #84873

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/sql/colexec/parallel_unordered_synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,19 @@ func (s *ParallelUnorderedSynchronizer) Close(ctx context.Context) error {
// Note that at this point we know that the input goroutines won't be
// spawned up (our consumer won't call Next/DrainMeta after calling Close),
// so it is safe to close all closers from this goroutine.
for i, span := range s.tracingSpans {
if span != nil {
span.Finish()
s.tracingSpans[i] = nil
}
}
var lastErr error
for _, input := range s.inputs {
if err := input.ToClose.Close(ctx); err != nil {
lastErr = err
}
}
// Finish the spans after closing the Closers since Close() implementations
// might log some stuff.
for i, span := range s.tracingSpans {
if span != nil {
span.Finish()
s.tracingSpans[i] = nil
}
}
return lastErr
}