Skip to content

fix(backend): tolerate transient query failure in sync backfill sweep tick - #21140

Open
kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/21122-sweep-query-resilience
Open

kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/21122-sweep-query-resilience

Conversation

@kodjima33

@kodjima33 kodjima33 commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

uid_sequencer.sweep() already wraps every per-owner and per-pending-job operation
in try/except, logging and continuing on failure so one bad item never kills the
whole scheduler tick. The two bulk queries that feed those loops — due_owners()
and due_pending() — were the only unguarded calls in the function. A transient
Firestore error from either query (e.g. ServiceUnavailable, DeadlineExceeded)
propagated straight out of sweep(), turning that one scheduler tick into an
HTTP 500 at /v2/sync-backfill-sequencer/sweep instead of degrading to a no-op
tick that the next ~2-minute scheduled run retries.

Wraps both queries the same way the rest of the function already treats
per-item failures: log the exception type and continue with an empty list for
this tick.

Why

Fixes #21122 — sync-backfill-uid-sequencer scheduler sweep returning
intermittent HTTP 500, trending from ~0.3% of ticks on Oct 4 to ~4.6% on Oct 9
(78 failures over 7 days). The issue reporter noted sweeps self-recover on the
next successful execution and there's no user-facing impact today, but the
error-rate trend is climbing with no bound, and an uncaught exception at the
query layer is the one place in this function that didn't already follow its
own established resilience pattern.

What I tested

Ran the full existing sequencer suite plus two new regression tests
(test_sweep_tolerates_due_owners_query_failure,
test_sweep_tolerates_due_pending_query_failure) that monkeypatch
due_owners/due_pending to raise and assert sweep() returns a degraded
outcome dict instead of raising:

backend/tests/unit/test_sync_backfill_uid_sequencer.py: 18 passed
backend/tests/unit/test_sync_backfill_alert_policy.py: passed
backend/tests/unit/test_recover_dev_failed_sync_backfill.py: passed
backend/tests/unit/test_dream_sweep.py: passed

Failure-Class: none

Auto-generated from issue feedback by the mini issues-improver — tested and merged.

View guided diff Turn on auto-fix

… tick

The sync-backfill-uid-sequencer scheduler sweep wraps every per-owner and
per-pending-job operation in try/except, but the two bulk queries that feed
those loops (due_owners, due_pending) were unguarded. A transient Firestore
error from either query (ServiceUnavailable, DeadlineExceeded, etc.)
propagated out of sweep() uncaught, turning one scheduler tick into an HTTP
500 at the /v2/sync-backfill-sequencer/sweep endpoint instead of degrading to
a no-op tick that the next scheduled run retries.

Wrap both queries the same way the rest of the function already treats
per-item failures: log and continue with an empty list for this tick.

fixes #21122

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync-backfill-uid-sequencer scheduler sweep returning intermittent HTTP 500

1 participant