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

jobs: refresh job details before removing protected timestamps #92586

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Nov 28, 2022

Fixes: #92493

Previously, we added the protected timestamps manager into the jobs frame work, which made it easier to automatically add and remove protected timestamps for jobs. Unfortunately, the Unprotect API when invoked from a clean up function never properly refreshed the job. Which could lead to a race condition trying to remove protected timestamps for schema changes. To address this, the Unprotect function will take advantage of the job update function to confirm that a refreshed copy does have protected timestamps set.

Release note: None

@fqazi fqazi requested a review from a team November 28, 2022 16:46
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @fqazi)


pkg/jobs/jobsprotectedts/jobs_protected_ts_manager.go line 205 at r1 (raw file):

// executing.
func (p *Manager) Unprotect(ctx context.Context, job *jobs.Job) error {
	return p.db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error {

I think you can simplify this to:

return job.Update(ctx, nil /* txn */, func(txn *kv.Txn, md jobs.JobMetadata, ju *jobs.JobUpdater) error {
   // check the job details here etc
})

Copy link
Collaborator Author

@fqazi fqazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner)


pkg/jobs/jobsprotectedts/jobs_protected_ts_manager.go line 205 at r1 (raw file):

Previously, ajwerner wrote…

I think you can simplify this to:

return job.Update(ctx, nil /* txn */, func(txn *kv.Txn, md jobs.JobMetadata, ju *jobs.JobUpdater) error {
   // check the job details here etc
})

Yes good point, should have done this much earlier

Done.

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @fqazi)

@fqazi fqazi marked this pull request as ready for review November 28, 2022 20:02
@fqazi fqazi requested a review from a team as a code owner November 28, 2022 20:02
@fqazi
Copy link
Collaborator Author

fqazi commented Nov 28, 2022

bors r+

Fixes: cockroachdb#92493

Previously, we added the protected timestamps manager into the jobs
frame work, which made it easier to automatically add and remove
protected timestamps for jobs. Unfortunately, the Unprotect API
when invoked from a clean up function never properly refreshed
the job. Which could lead to a race condition trying to remove
protected timestamps for schema changes. To address this, the
Unprotect function will take advantage of the job update function
to confirm that a refreshed copy does have protected timestamps
set.

Release note: None
@craig
Copy link
Contributor

craig bot commented Nov 28, 2022

Canceled.

@fqazi
Copy link
Collaborator Author

fqazi commented Nov 28, 2022

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 28, 2022

Build succeeded:

@craig craig bot merged commit 1bc257b into cockroachdb:master Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logictest: protected timestamp record does not exist
3 participants