Repository navigation
feat: prevent double backfill - #11377
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15652365a1
ℹ️ 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".
| DB_ERROR_METRIC, | ||
| 1, | ||
| &[("stage", "backfill_state_mark_running")], | ||
| return; |
There was a problem hiding this comment.
Retry backfill instead of exiting on an active lease
Returning here makes lease contention a one-shot decision, but init_if_enabled only spawns backfill_sessions once during startup (codex-rs/core/src/state_db.rs, lines 68-75). If a previous process crashed after setting status=running, a restart within the 900s lease window will hit !claimed and exit permanently, leaving backfill incomplete for the lifetime of that process and keeping DB-backed read paths unavailable until another restart.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Yes this is normal. We don't want a worker for this, we can live without the backfill
| SET status = ?, updated_at = ? | ||
| WHERE id = 1 | ||
| AND status != ? | ||
| AND (status != ? OR updated_at <= ?) |
There was a problem hiding this comment.
Refresh the lease during long-running backfill work
The stale-worker check is based solely on updated_at <= lease_cutoff, but this timestamp is only refreshed at claim time and at batch checkpoints; if processing one batch takes longer than the 900s lease, another process can successfully claim and start a duplicate backfill while the first worker is still running. This reintroduces the concurrent-worker behavior under large/slow backfills unless the lease is heartbeated more frequently.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
No chance this is the case unless you're on an intel Pentium on Windows 95
Summary
Add a DB-backed lease to prevent duplicate
.sqlitebackfill workers from running concurrently.What changed
Why
This avoids duplicate backfill work and reduces backfill status churn under concurrent startup, while preserving
current best-effort fallback behavior.