Skip to content

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

Description

@beastoin

Summary

The sync-backfill-uid-sequencer Cloud Scheduler job (us-central1, project based-hardware) is intermittently failing with HTTP 500 from the sweep endpoint. The failure rate is escalating.

This is unrelated to #19504 (dispatch 429 aborts, which are fixed). This is the scheduled sweep itself returning 500s.

Observed behavior

  • Target: /v2/sync-backfill-sequencer/sweep on backend-sync Cloud Run service
  • Error: URL_UNREACHABLE-UNREACHABLE_5xx — HTTP 500
  • Response latency: 20–28s on failures (same range as successful runs at 19–46s)
  • Schedule: runs every ~2 minutes

Failure trend (7-day)

Date Failures Failure rate
Oct 4 2 ~0.3%
Oct 5 2 ~0.3%
Oct 6 3 ~0.4%
Oct 7 5 ~0.7%
Oct 8 14 ~1.9%
Oct 9 33 ~4.6%
Oct 10 (partial) 19 ~4.1%

Total: 78 failures in 7 days. Trend: 2–3/day (Oct 4–6) → 14–33/day (Oct 8–10).

Impact

Failed sweeps self-recover on next successful execution. No user-facing impact observed.

GCP alert policy

  • Policy name: Sync backfill UID sequencer Scheduler execution failed
  • Metric: logging.googleapis.com/user/sync_backfill_uid_sequencer_scheduler_failure
  • Condition: above threshold of 0

cc @Git-on-my-level

by AI(chen) for @beastoin

Activity

  1. added
    p2
    on Oct 10, 2026
  2. beastoin commented on Oct 15, 2026

    @beastoin
    CollaboratorAuthor

    Update: Oct 14-15 — failure rate escalating, queue congested

    Failure trend (continued from Oct 10)

    Date Failure rate
    Oct 4-6 ~0.3%
    Oct 7 ~0.7%
    Oct 8 ~1.9%
    Oct 9 ~4.6%
    Oct 10 ~4.1%
    Oct 14 31.8%
    Oct 15 (partial) 52.9%

    Error pattern changed

    • Oct 4-10: HTTP 500 (URL_UNREACHABLE-UNREACHABLE_5xx)
    • Oct 14-15: 100% NotFound exceptions — Firestore documents missing during reconcile_uid calls

    Queue status

    • Dispatched jobs: 0 — zero jobs dispatching across all sweeps
    • Active leases at sweep scan cap (100), queued depth at cap (100)
    • Queue is fully congested — no new backfill work is being processed

    User impact

    • Users with pending backfills older than 12 hours: 50+
    • Oldest pending backfill: ~54.5 hours (~2.3 days)
    • Median pending age: ~43.9 hours

    Severity reassessment

    Original filing (Oct 10) assessed impact as Low with self-recovery. With zero dispatches and queue congestion, this is no longer self-recovering. Backfill processing is effectively stopped.

    cc @Git-on-my-level

    by AI(chen) for @beastoin

  3. added
    p1
    and removed
    p2
    on Oct 15, 2026
  4. hardik4love-lang commented on Oct 16, 2026

    @hardik4love-lang
    Contributor

    Submitted fix in PR #21811: #21811

    Root Cause Analysis

    1. Head-of-Line Blocking in sweep(): In �ackend/utils/sync/uid_sequencer.py (sweep()), when
      econcile_uid(owner['uid'], owner, ...) encountered an exception, it recorded outcome = 'error' and logged, but never called
      egistry.defer_owner(owner['uid'], ...)
      . Consequently, failing owners remained with
      econcile_at <= now and were re-queried on every single scheduler tick. When multiple owners failed, they filled all 100 slots in due_owners(limit=100), starving healthy accounts and completely halting backfill dispatching across all sweeps.
    2. Missing Document NotFound Handling: Transactional updates in defer_owner,
      edrive_job, �egin_job, and
      enew_job did not catch google.api_core.exceptions.NotFound (unlike defer_pending). When a document was concurrently deleted or missing, the update threw an unhandled 404/NotFound exception.
    3. Query Resilience: Transient timeouts during due_owners or due_pending query streams were unhandled at the outer tick boundary.

    Summary of Changes in PR #21811

    • Owner Deferral on Reconcile Error: In uid_sequencer.sweep(), when
      econcile_uid catches an exception, it now defers the owner by HEARTBEAT_SECONDS (
      egistry.defer_owner(owner['uid'], registry.HEARTBEAT_SECONDS, now=now)), immediately rotating the bounded page and unblocking the rest of the queue.
    • Firestore NotFound Resilience: Wrapped transactional commits in defer_owner,
      edrive_job, �egin_job, and
      enew_job with except NotFound: handlers to safely treat missing documents as non-fatal.
    • Query Stream Guarding: Wrapped due_owners() and due_pending() in sweep() to gracefully log due_owners_error / due_pending_error and continue remaining work without crashing.
    • Hermetic Unit Test Suite: Added 5 new unit tests in �ackend/tests/unit/test_sync_backfill_uid_sequencer.py verifying that failing owners are deferred and unblock subsequent owners, and that NotFound / query exceptions are handled cleanly. All 81 tests pass.
  5. hardik4love-lang commented on Oct 16, 2026

    @hardik4love-lang
    Contributor

    This critical P1 sync outage is now resolved in PR #21811 (merged by @kodjima33 into main):

    • Queue Head-of-Line Starvation Resolved: Unhealthy/failing owners are now deferred by HEARTBEAT_SECONDS, rotating the bounded due page and restoring dispatching for all healthy backfill jobs.
    • NotFound & Query Resilience: Missing documents during job renewal, deferral, and redrive are safely absorbed without aborting sweeps, and outer query failures no longer crash the scheduler loop.
    • Unit Tested: Full test suite added in backend/tests/unit/test_sync_backfill_uid_sequencer.py verifying multi-tick rotation and error tolerance.

    Bounty Claim Details

    @kodjima33 @josancamon19 @beastoin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions