GeezerVison is showing github.com — github-backup(drain): ack webhook events only after a successful fetch by dezren39 · Pull Request #3290 · developing-today/code
Conversation
dezren39
commented
Nov 1, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #3219
The bug
drain_queue.py appended every event id to the ack list up front and POSTed it to the Worker at the end of the run — including events whose fetch had just returned "fail" or "missing". The Worker deletes acked events from KV, so a transient fetch failure silently converted into up-to-a-week of staleness: the failure was written to no log, the 15-min coalesce stamp was advanced anyway, and the run summary printed the repo under fetched regardless of outcome.
The fix
An event is now acked only once the drainer has made the mirror reflect it:
- Planned repo, fetch attempted: ack iff
fetch_repo returned "ok". On "fail"/"missing" the event stays queued for the next drain tick, the failure is appended to fetch.log in the daily pass's leading format (plus drain context: oldest event age, consecutive-failure count), and the coalesce stamp is not advanced.
- Planned repo inside its coalesce window: the event stays queued (not acked); a drain after the window passes fetches and acks it. Coalesce stamps are written only on success.
- Unplanned repo: acked +
fetch.log note — preserved behavior (mirror creation is the weekly reconcile's decision).
- Retry guard: consecutive drain failures are counted per repo (
state.json key drain_fail::<repo>). At 5 consecutive failures the failure is logged loudly (DRAIN-CHRONIC … event(s) kept queued, needs attention) and the run exits non-zero so systemd surfaces it — mirroring the daily pass's chronic-failure pattern. The event is kept, never silently dropped; a later success clears the counter.
- Run summary now distinguishes
fetched vs failed (with per-repo result + failure count) vs unplanned vs coalesced_pending, plus the acked count. plan.json is loaded once instead of per repo.
Tests — before / after
New regression test infra/github-backup/tests/test_drain_queue.py drives the real drain_queue.main() with a stub Worker + stub fetch_repo (same shape as the probe in #3219): 32 checks across success / fail / missing / unplanned / coalesce-window / coalesce-expired / chronic / recovery / mixed-batch cases.
Before (test run against the pre-fix drain_queue.py on this branch's base):
{"events": 1, "fetched": ["owner/repo"]} <- summary claims success on a failed fetch
PASS success: exit 0
PASS success: event acked
PASS success: coalesce stamp set
PASS success: no fetch.log
FAIL fail: event NOT acked <- the bug: acked despite fetch failure
AssertionError: fail: event NOT acked
After:
including: fail → not acked + fetch.log line with event age + no stamp + counter incremented; missing → same; coalesce window → not acked and no fetch attempted, fetched+acked once the window passes; 5th consecutive failure → exit 1 + DRAIN-CHRONIC in fetch.log + event still queued; success after failures clears the counter.
Run locally on the laptop: python3 infra/github-backup/tests/test_drain_queue.py.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Events were acked (deleted from the Worker KV queue) even when the
fetch failed or the mirror was missing, and the coalesce stamp was
advanced anyway — a transient failure silently became up to a week
of staleness with no log. Now: ack only on fetch ok; failures stay
queued, are appended to fetch.log with the oldest event age, and are
counted per repo; at 5 consecutive failures the run logs DRAIN-CHRONIC
and exits non-zero (event still kept). Coalesce-window events stay
queued until a drain fetches them. Unplanned repos keep the previous
behavior (acked + noted for the weekly reconcile).
Regression test: infra/github-backup/tests/test_drain_queue.py (32 checks).
Fixes #3219
Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 19 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d06d9408-7e10-4a5a-996d-adcee8150cdc
Commits
-
Reviewing files that changed from the base of the PR and between cf1b243 and 50bf3c5.
Files selected for processing: 3
-
infra/github-backup/README.md
infra/github-backup/bin/drain_queue.py
infra/github-backup/tests/test_drain_queue.py
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-01T02:00:09.285780Z |
50bf3c5 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50bf3c579c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+147
to
+148
|
|
failed.append({"repo": repo, "result": res,
|
|
|
"consecutive_failures": fs["count"]})
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow queue polling to progress past retained failed events
If the queue contains 500 older events for unavailable planned mirrors, retaining those events now prevents later events for healthy repositories from being processed. The Worker in infra/github-backup/worker/src/index.js:55–61 returns only the first 500 entries and neither follows nor exposes a pagination cursor, so every drain retries the same failed batch until recovery or expiration of the seven-day TTL. I reproduced this with 500 missing-mirror events followed by one healthy-repository event: repeated drains never attempted the healthy repository. Preserve failed events, but add pagination or another mechanism that allows polling to advance past them.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 1, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|