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

sql: make cleanup jobs spawned by alter primary key not cancelable #45595

Merged
merged 1 commit into from
Mar 3, 2020
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
8 changes: 8 additions & 0 deletions pkg/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ type Record struct {
Details jobspb.Details
Progress jobspb.ProgressDetails
RunningStatus RunningStatus
// NonCancelable is used to denote when a job cannot be canceled. This field
// will not be respected in mixed version clusters where some nodes have
// a version < 20.1, so it can only be used in cases where all nodes having
// versions >= 20.1 is guaranteed.
NonCancelable bool
}

// StartableJob is a job created with a transaction to be started later.
Expand Down Expand Up @@ -375,6 +380,9 @@ func (j *Job) cancelRequested(
ctx context.Context, fn func(context.Context, *client.Txn) error,
) error {
return j.Update(ctx, func(txn *client.Txn, md JobMetadata, ju *JobUpdater) error {
if md.Payload.Noncancelable {
return errors.Newf("job %d: not cancelable", j.ID())
}
if md.Status == StatusCancelRequested || md.Status == StatusCanceled {
return nil
}
Expand Down
Loading