Skip to content

fix(sync): run direct backfill work at once when the UID sequencer is off - #21909

Merged
mdmohsin7 merged 2 commits into
mainfrom
rex/sync-sequencer-off-direct
Oct 16, 2026
Merged

mdmohsin7 merged 2 commits into
mainfrom
rex/sync-sequencer-off-direct

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

With SYNC_BACKFILL_UID_SEQUENCER=off, the backfill worker now processes direct backfill jobs immediately. Before this change it still sent them back into the one-per-UID queue whenever the user had an active or pending sequenced entry.

Why

#21883 turned the sequencer off, and it is off on both prod sync services now. Ten minutes after the switch, sequencer registrations were unchanged (1,414 → 1,594 per 10 min), and every one came from the backfill worker.

The worker's cutover branch (run_sync_job, epoch-less backfill payloads) did two things when the flag was off:

  • It re-registered the job into the sequencer if the user had an active owner or any pending entry.
  • Otherwise it called refresh_direct_run, which makes kick() defer that user's sequenced drain.

All 1,724 users with a backlog still have pending entries (502k total), so the kill switch changed nothing for them.

Change

  • The cutover branch now runs only when the sequencer is on. Flag off goes straight to _run_sync_job_body, and the already-sequenced entries keep draining through kick/Scheduler in parallel.
  • Sequenced deliveries (those carrying sequencer_epoch) are untouched. They still finish their job and kick the next one.

Trade-off: with the flag off, a user's direct jobs and their leftover sequenced jobs can run concurrently. That is the pre-sequencer behaviour, paced by the Cloud Tasks queue.

Product invariants affected

none

Failure class

Failure-Class: new

Adds FC-kill-switch-keeps-the-gated-path: a rollout flag turned off must stop admitting new work to the gated path, even while leftover state from the flag-on period exists.

Verification

  • test_old_backfill_task_migrates_on_flag_on_and_runs_direct_when_off now asserts that, with the flag off, a direct job runs and is not registered for an idle owner, an active owner, or a pending backlog, and that refresh_direct_run is never called. The old code registers in the last two cases, so the test fails on it.
  • test_sync_task_persistence_fence_terminalizes_backfill_and_releases_its_slot no longer pads the adoption read that the flag-off path no longer makes.
  • tests/unit/test_sync_cloud_tasks.py and tests/unit/test_sync_backfill_uid_sequencer.py: the same 11 failures as unmodified main in my local environment, and nothing new.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

… off

With SYNC_BACKFILL_UID_SEQUENCER=off, the worker still pulled any direct
backfill job back into the one-per-UID queue whenever that user had an
active or pending sequenced entry, and marked a direct run that paused the
queue's drain. Every user with a backlog therefore stayed fully serialized
after the kill switch, which is exactly the population the switch is for.

When the sequencer is off the worker now processes the job directly and
leaves the existing sequenced entries to drain in parallel.
@mdmohsin7
mdmohsin7 merged commit d9bdbbc into main Oct 16, 2026
52 of 54 checks passed
@mdmohsin7
mdmohsin7 deleted the rex/sync-sequencer-off-direct branch October 16, 2026 17:42
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.

1 participant