Skip to content

Commit

Permalink
Merge pull request cockroachdb#69991 from cockroachdb/blathers/backpo…
Browse files Browse the repository at this point in the history
…rt-release-21.2-69961

release-21.2: colexec: adjust the eager cancellation in parallel unordered sync a bit
  • Loading branch information
yuzefovich authored Sep 9, 2021
2 parents 1a33383 + c39a49f commit 99a4816
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
1 change: 0 additions & 1 deletion pkg/sql/colexec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ go_library(
"//pkg/sql/sqltelemetry", # keep
"//pkg/sql/types",
"//pkg/util",
"//pkg/util/cancelchecker",
"//pkg/util/duration", # keep
"//pkg/util/encoding", # keep
"//pkg/util/humanizeutil",
Expand Down
36 changes: 10 additions & 26 deletions pkg/sql/colexec/parallel_unordered_synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -249,30 +247,16 @@ func (s *ParallelUnorderedSynchronizer) init() {
switch state {
case parallelUnorderedSynchronizerStateRunning:
if err := colexecerror.CatchVectorizedRuntimeError(s.nextBatch[inputIdx]); err != nil {
if s.Ctx.Err() == nil && s.cancelLocalInput[inputIdx] != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, cancelchecker.QueryCanceledError) {
// The input context has been canceled, yet the
// main context of the synchronizer has not.
// This indicates that the synchronizer has
// transitioned into draining state and wanted
// this goroutine to stop whatever it was doing.
// Therefore, we swallow the error and proceed
// to draining.
//
// Note that we need the second part of the
// conditional in case the context cancellation
// was observed by the CancelChecker and was
// propagated as a query canceled error.
if util.CrdbTestBuild {
if s.getState() != parallelUnorderedSynchronizerStateDraining {
colexecerror.InternalError(errors.AssertionFailedf(
"unexpectedly the input context is canceled, the main " +
"context is not, and not in the draining state",
))
}
}
continue
}
if s.getState() == parallelUnorderedSynchronizerStateDraining && s.Ctx.Err() == nil && s.cancelLocalInput[inputIdx] != nil {
// The synchronizer has just transitioned into the
// draining state and eagerly canceled work of this
// input. That cancellation is likely to manifest
// itself as the context.Canceled error, but it
// could be another error too; in any case, we will
// swallow the error because the user of the
// synchronizer is only interested in the metadata
// at this point.
continue
}
sendErr(err)
return
Expand Down

0 comments on commit 99a4816

Please sign in to comment.