draft: choose fixed SQLite dependency path for WAL-reset corruption#24664
Closed
btraut-openai wants to merge 3 commits into
Closed
draft: choose fixed SQLite dependency path for WAL-reset corruption#24664btraut-openai wants to merge 3 commits into
btraut-openai wants to merge 3 commits into
Conversation
Codex uses pooled WAL-mode SQLite state databases, and the bundled SQLite 3.46.0 is affected by the documented WAL-reset corruption race. Bundle fixed SQLite 3.51.3 through a pinned libsqlite3-sys override and guard the linked runtime version in codex-state tests.
The vendored dependency source is not a Codex workspace crate, and its official amalgamation assets necessarily exceed the default blob budget. Keep the pinned source auditable under third_party and allowlist the required large upstream artifacts.
Do not carry SQLite amalgamation source in Codex. Leave the draft blocked on selecting an owner for a pinned external sqlx-sqlite 0.8.6 patch that can admit fixed libsqlite3-sys releases.
Contributor
Author
|
Rather than patching, it likely makes more sense to try to bump SQLx and Rust versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status: Blocked, Do Not Merge
Codex runtime state databases use pooled SQLite connections in WAL mode. SQLite documents a rare WAL-reset corruption bug affecting releases through
3.51.2when separate connections write or checkpoint concurrently, and shipped Codex Nightly/Alpha binaries bundle vulnerable SQLite3.46.0.Earlier today, my
~/.codex/state_5.sqliteencountered structural B-tree corruption after thread and spawned-agent state persistence, eventually preventing startup. A fixed engine is needed to prevent future exposure; installing one will not make an already-corrupted database trustworthy.This draft intentionally does not implement the fix. Its only code diff is a placeholder at the intended dependency-patch location while ownership of a pinned external dependency fork is decided.
Dependency Decision Needed
The narrow implementation path is a pinned external patch of
sqlx-sqlite 0.8.6that widens itslibsqlite3-sysdependency constraint to admit officiallibsqlite3-sys 0.37.0, which bundles fixed SQLite3.51.3. Upstream SQLx made this dependency relaxation in commitf5cdf3316d12ba0530486b4722a4114608fa1c84, but it is only published on the SQLx0.9line.Unfortunately there's no good non-alpha
sqlx-sqlitetarget that containslibsqlite3-syswith SQLite3.51.3+, so this draft is paused while I find the cleanest place to patch that constraint. I'm open to alternative solutions if there's something cleaner.Decision needed: which trusted repository should own the minimal
sqlx-sqlite 0.8.6fork and pinned revision used by Codex?Rejected options:
libsqlite3-sysor the SQLite amalgamation in Codex: it puts roughly 20 MB of third-party generated source in this repository and requires large-blob exceptions.0.9.0: it requires Rust1.94.0, while Codex's current Bazel toolchain is Rust1.93.0, and it broadens the change beyond the SQLite fix.Implementation After Decision
Once the fork owner is chosen, this draft should be replaced with the real change:
sqlx-sqlite 0.8.6override and resolve official fixedlibsqlite3-sys.codex-stateregression guard that queries the actually linkedsqlite_version()and rejects vulnerable releases.codexandcodex-app-serverartifacts embed fixed SQLite.Recovery And Rollout
Healthy existing databases require no schema migration; this is an engine fix, not a Codex schema change.
Already-corrupted databases require backup-and-rebuild recovery. The CLI flow preserves runtime SQLite files plus WAL/SHM sidecars before rebuilding queryable thread state from rollout JSONL. Database-only state may not be reconstructed. The standalone app-server/Desktop startup path does not currently expose an equivalent visible recovery flow, so that UX requires focused follow-up alongside Nightly/Alpha rollout and corruption telemetry.
Placeholder Verification
libsqlite3-syssource.just bazel-lock-check.python3 .github/scripts/verify_cargo_workspace_manifests.py.