Skip to content

Avoid no-op backfill state writes - #26420

Merged
zanie-oai merged 2 commits into
mainfrom
zb/avoid-backfill-noop-writes
Jun 9, 2026
Merged

Avoid no-op backfill state writes#26420
zanie-oai merged 2 commits into
mainfrom
zb/avoid-backfill-noop-writes

Conversation

@zanie-oai

Copy link
Copy Markdown
Contributor

Summary

  • avoid acquiring SQLite's writer slot when the singleton backfill row already exists
  • preserve race-safe repair when the row is missing
  • add regressions for writer contention and missing-row repair

Why

State runtime initialization and backfill-state reads previously executed
INSERT ... ON CONFLICT DO NOTHING even in the steady state. SQLite still
enters the writer path for that statement, so TUI and app-server startup could
wait behind another writer for up to the configured five-second busy timeout.

Validation

  • just test -p codex-state (134 tests passed)
  • just fix -p codex-state
  • just fmt

@zanie-oai
zanie-oai force-pushed the zb/avoid-backfill-noop-writes branch from c4f0578 to a1b5b9e Compare June 4, 2026 16:24
Comment thread codex-rs/state/src/runtime.rs Outdated
Co-authored-by: Zanie Blue <zanie@openai.com>
@zanie-oai
zanie-oai marked this pull request as ready for review June 4, 2026 16:46
@zanie-oai

Copy link
Copy Markdown
Contributor Author

In the common case, this causes no change in performance, e.g., there's no cost to do the extra check and the extra check doesn't save us anything, but when there's a writer holding a lock the startup can wait up to 5s for no reason — this eliminates that wait.

@zanie-oai
zanie-oai requested a review from jif-oai June 4, 2026 20:34
@zanie-oai
zanie-oai merged commit 18ce671 into main Jun 9, 2026
31 checks passed
@zanie-oai
zanie-oai deleted the zb/avoid-backfill-noop-writes branch June 9, 2026 15:50
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants