iteration: don't allow double-retrying a job#27
Merged
Conversation
Contributor
Huh https://github.com/Shopify/shopify/pull/168602 🙃 |
Contributor
|
Thanks Simon! |
Contributor
|
CI passed on Shopify Core pointed to this branch. |
Contributor
|
Thanks, Simon! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #26
If a job ends up calling
retry_jobin itson_shutdownhook either directly or indirectly (through a retry extension that re-enqueues on execution error) andshould_job_exit?is true (e.g. exceedingIteration.max_job_runtime)—then the job will get double-enqueued. This can cause exponential job growth.Example. Imagine that
Iteration.max_job_runtime = 5.minutesand a job will take 2 hours to complete. This means there's a total of(2 * 60) / 5 = 24interruptions. On each interruption, every job will spawn two jobs. This will lead to a total of2^24 = 16 millionjobs in just a span of about 2 hours.Discussion.
super unless @retriedseems fairly heavy-handed, and I worry about how it'll interface with downstream dependencies. Likely, bumping this inshopify/shopify's test suite will reveal problems with this approach. That said, I can't think of a legit use-case for callingretry_jobtwice in the same context. This seems like a sensible thing to guard against and we've missedunless @retriedrepeatedly. That said, I'd be surprised if @kirs hasn't considered porting this into the monkey-patch since he's suffered the most pain with these conditionals for double-reenqueue. An alternative would be to try to teach retry logic about iteration, but that almost feels more ugly.