fix(queue): retry a transient GitHub mergeable_state read before deferring to the next sweep#8560
Merged
Merged
Conversation
…rring to the next sweep Live incident: metagraphed#8037 (and others) sat unmerged for ~6 minutes after being approved, gate-passing, and fully-autonomous-merge-configured (autonomy.merge: auto, requireApprovals: 0). GitHub computes mergeable_state ASYNCHRONOUSLY after a push/review and can return "unknown" (still computing) even on the forced live re-fetch taken moments after posting the approving review -- the disposition correctly refused to merge into an unconfirmed state, but simply deferred to the next scheduled regate sweep (~6 minutes later) instead of retrying. That multi-minute window is exactly where an overlapping sibling PR can land first and base-conflict the original PR out from under it. refreshLiveMergeState now retries a short, bounded number of times (2) SPECIFICALLY on "unknown" -- "dirty"/"blocked"/"behind" are real, stable, non-computing states and are never retried -- before falling through to the same defer-to-sweep behavior as before. Mirrors the identical GitHub-lag pattern already used for diff/files computation (fetchAndStorePullRequestFilesForReview). Test-only delay override via the same vitest-setup.ts suite default this session's other perf fixes use, so the retry's own logic is exercised without adding real wall-clock time to the suite.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8560 +/- ##
==========================================
- Coverage 92.51% 92.50% -0.01%
==========================================
Files 795 795
Lines 79613 79622 +9
Branches 24056 24058 +2
==========================================
+ Hits 73653 73657 +4
Misses 4800 4800
- Partials 1160 1165 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
Live incident: metagraphed#8037 (and others) sat unmerged for ~6 minutes after being approved, gate-passing, and fully-autonomous-merge-configured (
autonomy.merge: auto,requireApprovals: 0). GitHub computesmergeable_stateasynchronously after a push/review and can return"unknown"(still computing) even on the forced live re-fetch taken moments after posting the approving review — the disposition correctly refused to merge into an unconfirmed state, but simply deferred to the next scheduled regate sweep (~6 minutes later) instead of retrying. That multi-minute window is exactly where an overlapping sibling PR can land first and base-conflict the original PR out from under it — metagraphed#8037's own review panel had already flagged 2 such overlapping siblings (#8040, #8036).refreshLiveMergeStatenow retries a short, bounded number of times (2) specifically on"unknown"—"dirty"/"blocked"/"behind"are real, stable, non-computing states and are never retried — before falling through to the same defer-to-sweep behavior as before. Mirrors the identical GitHub-lag pattern already used for diff/files computation (fetchAndStorePullRequestFilesForReview).Validation
ci-resolution.test.ts: retries once and resolves to"clean"within the same pass; gives up after the retry cap and still returns"unknown"(unchanged fallback behavior); does not retry a real"dirty"state; does not retry an outright fetch failure.fetchLivePullRequestMergeStatedirectly (not throughrefreshLiveMergeState) are unaffected — confirmed by running them.npm run typecheckclean;npm run test:coverage(full, unsharded): 21,486 passed / 0 failed.test/helpers/vitest-setup.tsdefault (from perf(test): eliminate SQLite fsync and real rate-limit backoff wait in tests #8553), so the retry's own logic is exercised without adding real wall-clock time to the suite.