Desktop should bound and compact logs_2.sqlite before it becomes recovery pressure
Summary
Codex Desktop needs a bounded local log DB lifecycle before large logs_2.sqlite files become app-server/renderer recovery pressure. The immediate renderer freeze I investigated had a local ~/.codex/logs_2.sqlite around 952 MB.
There are already several issues about TRACE rows and SQLite growth. This issue is specifically about the recovery/user-impact invariant: a large local diagnostic DB should not make the Desktop UI repeatedly freeze or require users to manually delete SQLite files to recover.
Local evidence
On the affected macOS profile:
~/.codex/logs_2.sqlite ~952 MB
~/.codex/state_5.sqlite ~6.4 MB
The Desktop app-server and bridge/helper processes were still alive while the renderer was the problematic process. That suggests two interacting pressures:
- the renderer receives too many live events during active streaming/tool turns;
- persisted local log/state databases remain large across restarts, so quitting/reopening does not necessarily remove the pressure.
Raw log rows are intentionally not included because local logs can contain private paths and session content.
Problem
Even if retention/checkpointing exists, the current behavior still allows a normal Desktop profile to reach a very large local log DB. Once that happens, the failure mode is sticky:
- relaunching the app can reuse the same large local DB;
- app-server startup/recovery may contend on or scan local SQLite state;
- renderer recovery or diagnostics can be affected by the same persisted state;
- users do not get a clear safe-mode or repair path.
Suggested fix
Add an explicit bounded log lifecycle for Desktop profiles:
- do not persist
TRACElogs by default unless an explicit debug flag is enabled; - enforce a byte and row cap for
logs_2.sqlite, not just age-based retention; - checkpoint/truncate WAL under normal multi-process Desktop usage;
- run maintenance before hot startup/resume paths that can affect renderer responsiveness;
- if the DB exceeds a safety threshold, show a repair/safe-mode path instead of letting the renderer freeze;
- separate renderer-critical state from diagnostic logs so the UI does not depend on reading or reconciling an oversized log store;
- expose a supported command such as
codex logs compactor automatic profile maintenance.
Expected behavior
A Desktop profile should recover cleanly even if its log DB is large. Users should not need to discover and manually delete ~/.codex/logs_2.sqlite* to restore responsiveness.
Related issues
This overlaps with, but does not fully replace:
- #30322
- #24275
- #27741
- #29532
- #30162
- #30405
- #25779
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This still looks like the right umbrella issue for the log lifecycle policy, with #30517 as the CLI startup symptom.
From current
main(ccdfb4f), the relevant owner is the shared state runtime rather than Desktop-only code:codex_state::LOGS_DB_FILENAMEislogs_2.sqliteStateRuntime::init_inner()opens/migrates the logs DB alongside state/goals/memories DBsrun_logs_startup_maintenance()deletes rows older than retention and then runsPRAGMA wal_checkpoint(PASSIVE)log_dblayer, but DB open and startup maintenance can still affect first-run/startup behaviorThe policy I would expect from this issue:
logs_2.sqlite-wal, not just retained rows inlogs_2.sqlitecodex doctoror a safe-mode startup path should report log DB/WAL size and checkpoint healthcodex logs compactor equivalent, so users do not need to manipulate SQLite files directlyThat keeps #30431 as the shared invariant, while #30517 can validate the specific “large/busy WAL stalls CLI prompt” case.
Additional Windows confirmation on Codex CLI 0.144.1 / Desktop 26.707.3748: the live log SQLite family currently totals 477.05 MiB, with the largest database at 463.55 MiB. No manual deletion, VACUUM, or live compaction was attempted because there is no documented supported maintenance path. A supported size metric, warning threshold, byte/row cap, and safe compact command would prevent operators from improvising against a live database. No raw rows or private paths are included.
Here is a summary of related issues bogging down the VSCode extension (assessed and composed by GPT 5.6 Sol Ultra):
Linux ARM64 / VS Code confirmation
26.707.314280.144.0-alpha.4CODEX_HOMEThe extension repeatedly failed to load, although app-server initialized normally and logged no panic, migration, authentication, or SQLite error. All quarantined databases passed
PRAGMA quick_check.logs_2.sqlitehad processed 2.94 million inserts while retaining only 1,752 rows. Its pages were 91.6% free, its WAL was 8.8 MB, and roughly 84% of retained rows were dependency TRACE events, despiteRUST_LOG=warn.Quarantining the SQLite files and reinstalling the extension restored operation, although both changes occurred together. A fresh log database then resumed rapid growth, reaching a 4.3 MB WAL within roughly ten minutes.
This appears to be a valid-but-pathological logging database that bypasses corruption recovery and leaves the extension looking healthy to telemetry while being unusable to the user.