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, *: remove job Resumer OnSuccess and OnTerminal #45829

Merged
merged 2 commits into from
Mar 7, 2020
Merged

Conversation

dt
Copy link
Member

@dt dt commented Mar 7, 2020

This eliminates the OnSuccess and OnTerminal methods from the job Resumer API.

The OnSuccess method is clearly duplicative with Resume: it is called when, and only when, Resume() has returned successfully, so whatever work it was going to do could just be done at the end of Resume instead -- and almost all implementations had already been refactored to do so. There was no need to share a txn with moving the job to the terminal state -- the job itself can use a txn to do whatever work it wants, optionally updating a field in the job progress or details with that same txn if it wants those semantics.

The OnTerminal method is similarly surplus to requirements -- whatever it was doing can simply be done at the end of both Resume and OnFailOrCancel. In practice, most OnTerminals were entirely logic conditional on success, to push rows into the result channel, making it trivial to simply move that code to the end of Resume.

Release note: none.

dt added 2 commits March 7, 2020 03:48
We can just do whatever it was doing in Resume to simplify state machine.

Release note: none.
Whatever it was doing can be done in Resume or OnFailOrCancel,
both of which are resumable (and most of these were only doing
things on success anyway so they should just be last step of
Resume).

Release note: none.
@dt dt requested review from pbardea and spaskob March 7, 2020 03:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dt dt requested a review from ajwerner March 7, 2020 03:49
Copy link
Contributor

@spaskob spaskob left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for tackling this! Please also stress test jobs_test.go.

Reviewed 9 of 9 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @pbardea)

@dt
Copy link
Member Author

dt commented Mar 7, 2020

303 runs so far, 0 failures, over 5m0s

@dt dt merged commit eac401f into cockroachdb:master Mar 7, 2020
@dt dt deleted the on-term branch March 7, 2020 22:58
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.

4 participants