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

changefeedccl: Do not inhibit node shutdown #82768

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
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
9 changes: 3 additions & 6 deletions pkg/ccl/changefeedccl/changefeed_processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,14 @@ func (ca *changeAggregator) MustBeStreaming() bool {

// Start is part of the RowSource interface.
func (ca *changeAggregator) Start(ctx context.Context) {
// Derive a separate context so that we can shutdown the poller.
ctx, ca.cancel = ca.flowCtx.Stopper().WithCancelOnQuiesce(ctx)

if ca.spec.JobID != 0 {
ctx = logtags.AddTag(ctx, "job", ca.spec.JobID)
}
ctx = ca.StartInternal(ctx, changeAggregatorProcName)

// Derive a separate context so that we can shutdown the poller. Note that
// we need to update both ctx (used throughout this function) and
// ProcessorBase.Ctx (used in all other methods) to the new context.
ctx, ca.cancel = context.WithCancel(ctx)
ca.Ctx = ctx

spans, err := ca.setupSpansAndFrontier()

endTime := ca.spec.Feed.EndTime
Expand Down
7 changes: 6 additions & 1 deletion pkg/ccl/changefeedccl/changefeed_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,12 @@ func (b *changefeedResumer) resumeWithRetries(
}
}

if !changefeedbase.IsRetryableError(err) {
// Retry changefeed is error is retryable. In addition, we want to handle
// context cancellation as retryable, but only if the resumer context has not been cancelled.
// (resumer context is canceled by the jobs framework -- so we should respect it).
isRetryableErr := changefeedbase.IsRetryableError(err) ||
(ctx.Err() == nil && errors.Is(err, context.Canceled))
if !isRetryableErr {
if ctx.Err() != nil {
return ctx.Err()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/changefeedbase/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//pkg/clusterversion",
"//pkg/jobs/joberror",
"//pkg/jobs/jobspb",
"//pkg/roachpb",
"//pkg/settings",
"//pkg/sql",
"//pkg/sql/catalog",
Expand Down
5 changes: 4 additions & 1 deletion pkg/ccl/changefeedccl/changefeedbase/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"

"github.com/cockroachdb/cockroach/pkg/jobs/joberror"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/sql/flowinfra"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -117,7 +118,9 @@ func IsRetryableError(err error) bool {
return true
}

return (joberror.IsDistSQLRetryableError(err) || flowinfra.IsNoInboundStreamConnectionError(err))
return (joberror.IsDistSQLRetryableError(err) ||
flowinfra.IsNoInboundStreamConnectionError(err) ||
errors.HasType(err, (*roachpb.NodeUnavailableError)(nil)))
}

// MaybeStripRetryableErrorMarker performs some minimal attempt to clean the
Expand Down