Repository navigation
Keep job leases through transient errors, stop handlers that lost them, and release jobs on shutdown - #2596
Merged
Conversation
…m, and release jobs on shutdown
… the handler as done
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.
Closes #2592
What
Fixes from the post-merge review of #2536, the job queue from ADR-0010.
JobQueueWorker.KeepLeaseAsyncrenews at a third of the lease until the handler is done. The lease is counted from just before the claim.IJobLeases.ReleaseAsync(jobId, owner). The update is guarded by the owner, like every other lease change.MaxRetryDelay, so no attempt count overflowsTimeSpanand skipsRetryAsync.Why
A 20-minute handler with no progress that hit one transient database error at minute 2 lost its lease for good. Another worker then claimed the job and ran it at the same time. A graceful restart used up an attempt, so a job on its last attempt ended dead. The retry delay threw from attempt 36 with the 30-second default.
Choices worth a look:
TimeProvider. No wait and no renewal outlasts it, so a slow or hanging database stops the handler when the lease ends, not a beat or a command timeout later. After that another worker may claim the job.RetryDelay, so its rules are tested without a database or the wall clock.Tests
Integration, each on SQLite and PostgreSQL:
Integration, SQLite:
Unit:
int.MaxValueis the ceiling, and a zero delay stays zero.The job tests passed three runs in a row on both providers. The full suite ran locally against a
postgres:17container as well as SQLite, and markdownlint passes. No new package and no new project reference.Checklist
v2