GeezerVison is showing github.com — github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking · Issue #6572 · developing-today/code
github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking #6572DescriptionProblem
queue_events() in infra/github-backup/bin/drain_queue.py:95-122 follows Worker queue pages in an unbounded while True loop. It guards two stuck shapes — a missing/empty cursor (:114-115) and a repeated cursor (:116-118) — but a page stream that always returns list_complete: false with a fresh, never-repeated cursor loops forever:
- every iteration performs another
worker_req HTTP request (60 s timeout each, :73) and events.extend(page_events) (:109), so the accumulated event list grows without bound in memory;
queue_events never returns, so main() never reaches the ack policy, the state.json write, or exit — no event is acked, no failure is logged, and the run never surfaces an error;
- the drainer runs as a
Type=oneshot systemd service on a 5-minute timer (infra/github-backup/systemd/github-backup-drain.service / .timer, no TimeoutStartSec in the unit), so one stuck drain wedges the webhook freshness layer until something external kills it.
The Worker side (infra/github-backup/worker/src/index.js:60-82) passes Cloudflare KV's list.cursor / list_complete straight through, so the cursor stream is an external system's output, not something the drainer controls. A KV listing that keeps producing incomplete pages with advancing cursors — e.g. during a large backlog drain (the queue has held ~5.9k events, #5496) while new webhook events keep being written — is exactly the shape with no exit.
Evidence (verified this run, laptop @ origin/main 26f51c3)
Probe ~/git/fleet/probe-ghb-drain-pages/probe.py imports the real drain_queue module and stubs only worker_req:
- Control, 2 pages then
list_complete: true → returns 2 events in 2 calls. ✅
- Repeated cursor →
RuntimeError: Worker queue pagination cursor repeated. ✅ (existing guard)
- Missing cursor with
list_complete: false → RuntimeError: Worker queue response is incomplete but has no cursor. ✅ (existing guard)
- Defect: every page returns
list_complete: false with a novel cursor (cursor-1, cursor-2, …) and one event → the loop was still running at 5,000 fetched pages / 5,000 accumulated events when the probe stopped it externally with its own sentinel exception. queue_events raised no error of its own and never returned.
Sibling oracles in this repo guard the same failure mode by progress, and one sibling already had the missing-cursor half of this bug filed: ghb_common.inventory_owner (#6532, null endCursor re-fetching page 1 forever), and pkgs/cold-store-reaper/cold_store.py s3_list_objects / list_backups, whose docstrings call out "would loop forever, appending duplicates" and raise on missing/repeated continuation tokens. The drain loop is missing the remaining half: a bound.
Why it matters
The drainer is the freshness layer of the github-backup system (webhook events → mirror fetches, every 5 minutes). A single stuck page stream silently freezes it: mirrors stop reflecting pushes, events pile up in the Worker queue un-acked, and nothing logs or exits non-zero, so systemd shows a running/failed unit rather than the chronic-failure alarms the rest of this system was built to raise (#3219/#3300 pattern). Unbounded in-memory accumulation is a second, slower failure on top.
Acceptance criteria
-
queue_events terminates with a loud error (non-zero drain exit, naming the pagination bound that was hit) when a Worker page stream exceeds a bounded budget — e.g. a maximum page count and/or a maximum total accumulated events; the exact bound is triage's call, but it must be comfortably above the largest legitimate backlog (the queue has held ~5.9k events; pages are 500 events).
- No event from an aborted poll is acked (the existing fail-closed-before-ack property is preserved).
- Regression tests in
infra/github-backup/tests/test_drain_queue.py style: novel-cursor-never-complete stream raises after the bounded number of pages; the existing two-page, repeated-cursor, and missing-cursor cases still pass.
- The legitimate multi-page drain (healthy events beyond 500 retained failures, existing test 14) still completes.
Distinct from #6532 (inventory_owner GraphQL cursor in ghb_common.py) and #3240 (non-atomic state files): this is the drainer's Worker-KV pagination loop in drain_queue.py. Activitydeveloping-today commented on Nov 6, 2026 dezren39 commented on Nov 6, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-a)
- Session / ID: new-issue-creator-code-a cron run, 2026-11-06 10:35 CST
- Found via: filed this run
- Task: Filed issue github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking #6572 — drain_queue.queue_events pagination has no page/event bound; a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events in memory and never reaching the ack policy. Verified on the laptop @ origin/main 26f51c3 with probe ~/git/fleet/probe-ghb-drain-pages (real drain_queue module, stubbed worker_req): 2-page control returns, repeat/missing-cursor guards raise, novel-cursor stream still looping at 5,000 pages when stopped externally.
- Expectation: effort s; done = triage verdict, then a bounded-pagination fix with regression tests per the issue's acceptance criteria.
- Links: issue github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking #6572; queue packet to be enqueued this run (repo-health-code-pilot, triage)
dezren39 commented on Nov 6, 2026 dezren39 commented on Nov 7, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), lane code-p
- Session / ID: repo-queue-worker-shift-p cron run 2026-11-06 20:17 CST — FALLBACK MODE (queue backend down, HTTP 503 PGRST002; fallback claim marker is the claim of record for issue github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking #6572, no broker task id exists this shift)
- Found via: queue fallback scan (queue/queued label, scan order)
- Task: implement the fix for issue github-backup(drain): queue_events pagination has no page/event bound — a Worker page stream with fresh cursors and list_complete=false loops forever, accumulating events and never acking #6572 — bound queue_events() pagination in infra/github-backup/bin/drain_queue.py with named page/event bounds + regression tests. Triage already CONFIRMED (lane code-r, task 11233); this issue is Phase 2 of design Design: complete, bounded, or say so — one pagination contract for the repo's paged reads #6622 and independent of Phase 1 in code, bound value is the fixer's call as a named constant
- Expectation: effort s–m; done = fix on a branch + PR, targeted tests passing on the laptop, merged if verified
- Links: claim marker comment above
dezren39 commented on Nov 7, 2026
Heartbeat: implementation_complete + targeted_tests_passed — branch queue/6572-drain-pagination-bound in laptop worktree ~/git/fleet/6572: MAX_QUEUE_PAGES=100 / MAX_QUEUE_EVENTS=50_000 named bounds in queue_events(), errors name the bound hit, fail-closed before ack preserved. test_drain_queue.py: 89/89 checks pass on the laptop (7 new scenario-17 checks: novel-cursor stream raises exactly at the bound, huge-page stream trips the event bound, completion exactly at the bound returns). Independent probe of the filing run's defect shape: raised after exactly 100 pages. Next: commit, PR, Codex/CI check, merge if clean. dezren39 commented on Nov 7, 2026
Released by repo-worker-code-p (fallback mode): issue #6572 fixed and merged via PR #6702 (#6702, merge 2aa4143) — queue_events() pagination now bounded by MAX_QUEUE_PAGES=100 / MAX_QUEUE_EVENTS=50_000 with bound-naming RuntimeErrors, fail-closed before ack. Verified: test_drain_queue.py 89/89 on the laptop (7 new scenario-17 checks), independent defect-shape probe raised at exactly 100 pages, Codex review on PR #6702 completed with no findings, fix confirmed present on main. Issue auto-closed by the PR's Fixes line. dezren39 commented on Nov 7, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|