Skip to content

doctor: rollout DB / state DB parity warnings accumulate (231 missing active rows, 179 stale rows, 45 duplicate thread ids) #55933

Open

Description

@3lancer

Summary

codex doctor reports persistent state.rollout_db_parity warnings. The app itself works fine — thread histories are intact — but the state DB thread inventory and the rollout files on disk drift apart over time, and there is no built-in way to reconcile them.

Environment

  • OS: Windows 11 Professional 10.0.26300 (de-DE), 64-bit
  • Codex CLI: 0.163.0-alpha.11 (C:\Users\<user>\AppData\Local\OpenAI\Codex\bin\6257d9e8f63c0f2b\codex.exe)
  • Codex Desktop: 26.1016.6573.0
  • Auth mode: ChatGPT; model provider: openai
  • Install context: desktop-managed binary (also codex.cmd shim via npm on PATH)

Doctor findings (state.rollout_db_parity)

  • rollout DB rows: 6072 (active files: 5349, archived files: 781)
  • 231 missing active rows — rollout files on disk with no matching threads row
  • 6 missing archived rows
  • 179 stale rows — DB rows pointing at missing/unusable rollout files (note: stale paths use \\?\C:\… extended-length prefixes, which may contribute to the mismatch)
  • 45 duplicate rollout thread ids (0 duplicate DB paths)
  • rollout DB sources: subagent:other=2994, subagent:thread_spawn=1849, vscode=1218, exec=10, cli=1

The doctor's own remedy for the duplicates: "Attach the doctor report to a bug report so support can inspect samples." — full codex doctor --json report: https://gist.github.com/3lancer/67f65a6a49a95b1101c50c0fc8b8daf2

Additional observations

  1. Threads whose rollout file no longer exists on disk still open and display correctly in the Desktop app, because migrated histories live in thread_history_1.sqlite. So at least part of the "stale rows" class appears to be a cosmetic index inconsistency rather than data loss — but doctor cannot distinguish that.
  2. The mismatch counts grow with usage (heavy subagent/thread_spawn usage in this installation).
  3. Manual attempts to clean state_5.sqlite threads rows are risky: deleting rows for files that are "missing" also removes still-functional migrated threads. A supported repair path is needed.

Suggestion

  • Provide codex doctor --fix (or a dedicated reindex command) that reconciles state_5.sqlite against the rollout directory and thread_history_1.sqlite, deduplicates thread ids, and normalizes \\?\-prefixed paths.
  • Alternatively, document the intended lifecycle so the parity check can ignore legitimately-migrated threads.

Activity

  1. added
    bug
    CLI
    windows-os
    session
    on Oct 21, 2026
  2. github-actions commented on Oct 21, 2026

    @github-actions
    Contributor
  3. simfor99 commented on Nov 3, 2026

    @simfor99

    One major source of the DB rows pointing at missing rollout files drift class on Linux/WSL2 is manual disk cleanup: because ~/.codex/sessions/ grows to tens of GBs (#41806, #34061), users delete old rollout-*.jsonl files by hand, which leaves orphaned rows in state_5.sqlite (threads, thread_dynamic_tools, thread_attachments, guardian_review_feedback, thread_read_receipts, thread_spawn_edges) and thread_history_1.sqlite (thread_items, thread_turns, thread_realtime_items, thread_history_projection_state).

    Two details we found while building deterministic reconciliation for this:

    1. thread_history_1.sqlite has an AFTER DELETE ON thread_history_projection_state trigger (thread_realtime_items_projection_cleanup), and state_5.sqlite has threads.attached_thread_parent_id self-references that must be nulled before deleting expired parent thread rows.
    2. Deleting the orphaned rows alone does not reclaim the multi-GB disk footprint of thread_history_1.sqlite or state_5.sqlite until VACUUM runs while neither the .sqlite file nor its -wal/-shm sidecars are held open in /proc/*/fd.

    We open-sourced our implementation that keeps ~/.codex/sessions/ and both SQLite databases in sync (with --dry-run default, /proc/*/fd active-file checks, fail-closed is_pinned = 1 protection, and free-space-checked VACUUM): https://github.com/simfor99/codex-hdd-guard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugsessionwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions