fix(dispatcher): retry transient ClaimDue failures and give the claim a longer timeout - #12
Closed
devin-ai-integration[bot] wants to merge 1 commit into
Closed
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
… a longer timeout
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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.
Summary
On Cloud Run, cold CPU allocation and idle-pool reconnects push the first few
ClaimDuecalls past the 5sQueryTimeoutDuration, producing recurringfailed to claim due notifications / context deadline exceededERROR logs even though nothing is actually wrong.store.ClaimTimeoutDuration = QueryTimeoutDuration*2(10s) now boundsClaimDue, since it opens a transaction and runs aFOR UPDATE SKIP LOCKEDselect plus an update rather than a single query.dispatchDueNotificationsnow claims viaclaimDueNotifications, which retries up todispatcherClaimRetries(2) extra times with adispatcherClaimRetryBackoff(2s) pause, only whenisTransientClaimError(err):context.DeadlineExceeded(incl. wrapped),pgconn.SafeToRetry/pgconn.Timeout, anynet.Error, andPgErrorclasses 08xx / 40001 / 40P01 / 57P01-03.42P01, opaque errors) returns immediately, so a real outage still logs once per tick. Retries also stop as soon as the dispatcher ctx is cancelled, and a cancelled-ctx failure (shutdown) is no longer logged as an error.dispatchDueNotificationsAt(ctx, startup=true): if it still ends inDeadlineExceededafter retries, it logs at Warn instead of Error.Tests:
TestClaimDueNotifications(success on 2nd attempt, wrapped deadline, retry budget exhausted, permanent PgError / opaque error not retried, no retry after ctx cancel) andTestIsTransientClaimError.Link to Devin session: https://app.devin.ai/sessions/40339faccc2c46948d4a8fb2bee608e5
Open in Devin Desktop: https://app.devin.ai/desktop/session/40339faccc2c46948d4a8fb2bee608e5?variant=devin
Requested by: @balebbae