Skip to content

[codex-backend] Make thread metadata updates tolerate pending backfill - #16877

Merged
joeytrasatti-openai merged 1 commit into
mainfrom
joeytrasatti-openai/codex-backend-thread-metadata-db-fallback
Apr 6, 2026
Merged

joeytrasatti-openai merged 1 commit into
mainfrom
joeytrasatti-openai/codex-backend-thread-metadata-db-fallback

Conversation

@joeytrasatti-openai

Copy link
Copy Markdown
Contributor

Summary

Fix thread/metadata/update so it can still patch stored thread metadata when the list/backfill-gated get_state_db(...) path is unavailable.

What was happening:

  • The app logs showed thread/metadata/update failing with sqlite state db unavailable for thread ....
  • This was not isolated to one bad thread. Once the failure started for a user, branch metadata updates failed 100% of the time for that user.
  • Reports were staggered across users, which points at local app-server / local SQLite state rather than one global server-side failure.
  • Turns could still start immediately after the metadata update failed, which suggests the thread itself was valid and the failure was in the metadata endpoint DB-handle path.

The fix:

  • Keep using the loaded thread state DB and the normal get_state_db(...) fallback first.
  • If that still returns None, open StateRuntime::init(...) directly for this targeted metadata update path.
  • Log the direct state runtime init error if that final fallback also fails, so future reports have the real DB-open cause instead of only the generic unavailable error.
  • Add a regression test where the DB exists but backfill is not complete, and verify thread/metadata/update can still repair the stored rollout thread and patch gitInfo.

Relevant context / suspect PRs:

Testing

  • cargo fmt -- --config imports_granularity=Item completed; local stable rustfmt emitted warnings that imports_granularity is unstable
  • cargo test -p codex-app-server thread_metadata_update
  • git diff --check

@joeytrasatti-openai
joeytrasatti-openai marked this pull request as ready for review April 6, 2026 17:07
@joeytrasatti-openai
joeytrasatti-openai merged commit 4ce97ce into main Apr 6, 2026
29 of 30 checks passed
@joeytrasatti-openai
joeytrasatti-openai deleted the joeytrasatti-openai/codex-backend-thread-metadata-db-fallback branch April 6, 2026 17:07
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 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