Current CLI startup can stall before the TUI prompt when logs_2.sqlite/WAL is large or busy
Disclosure: this report was drafted by ChatGPT/Codex using gpt-5.5 with high reasoning effort after the user asked why Codex startup was slow on this VM.
What version of Codex CLI is running?
codex-cli 0.142.3
What subscription do you have?
Pro ($200/month)
Which model were you using?
gpt-5.5
What platform is your computer?
Linux 7.0.10-arch1-1 x86_64 unknown
Additional context: this is a VM backed by spinning/platter hard drives. That
makes the problem easier to notice than it would be on an SSD, but the local
state size seems large enough that the behavior is still worth reporting.
What terminal emulator and version are you using (if applicable)?
SSH session inside tmux.
The environment varied between the shell used for investigation and thecodex doctor --json run, so the doctor output is probably the better source for
this field. The shell I used while investigating reported:
TERM=dumbTERM_PROGRAM=tmuxTMUX=/tmp/tmux-1000/default,506,6SSH_TTY=/dev/pts/0
codex doctor --json reported tmux 3.6b and TERM=st-256color from its own
detection path.
Codex doctor report
Full codex doctor --json output from the affected machine is included below, collapsed so the main report stays readable.
<details>
<summary>Full codex doctor --json output</summary>
{
"schemaVersion": 1,
"generatedAt": "1782702636s since unix epoch",
"overallStatus": "warning",
"codexVersion": "0.142.3",
"checks": {
"app_server.status": {
"id": "app_server.status",
"category": "app-server",
"status": "ok",
"summary": "background server is not running",
"details": {
"control socket": "/home/codex/.codex/app-server-control/app-server-control.sock",
"daemon state dir": "/home/codex/.codex/app-server-daemon",
"mode": "ephemeral",
"pid file": "/home/codex/.codex/app-server-daemon/app-server.pid (missing)",
"settings": "/home/codex/.codex/app-server-daemon/settings.json (missing)",
"status": "not running",
"update-loop pid file": "/home/codex/.codex/app-server-daemon/app-server-updater.pid (missing)"
},
"remediation": null,
"durationMs": 0
},
"auth.credentials": {
"id": "auth.credentials",
"category": "auth",
"status": "ok",
"summary": "auth is configured",
"details": {
"auth file": "/home/codex/.codex/auth.json",
"auth storage mode": "File",
"stored API key": "false",
"stored ChatGPT tokens": "true",
"stored agent identity": "false",
"stored auth mode": "chatgpt"
},
"remediation": null,
"durationMs": 0
},
"config.load": {
"id": "config.load",
"category": "config",
"status": "ok",
"summary": "config loaded",
"details": {
"CODEX_HOME": "/home/codex/.codex",
"config.toml": "/home/codex/.codex/config.toml",
"config.toml parse": "ok",
"cwd": "/home/codex/codex-src.git",
"enabled feature flags": "shell_tool, unified_exec, shell_snapshot, terminal_resize_reflow, sqlite, hooks, enable_request_compression, multi_agent, tool_search_always_defer_mcp_tools, tool_suggest, plugins, in_app_browser, browser_use, browser_use_full_cdp_access, browser_use_external, computer_use, plugin_sharing, image_generation, resize_all_images, skill_mcp_dependency_install, mentions_v2, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, personality, fast_mode, tui_app_server, auto_compaction, remote_compaction_v2, workspace_dependencies",
"feature flag overrides": "apps=false",
"feature flags enabled": "32",
"log dir": "/home/codex/.codex/log",
"mcp servers": "0",
"model": "gpt-5.5",
"model provider": "openai",
"sqlite home": "/home/codex/.codex"
},
"remediation": null,
"durationMs": 0
},
"git.environment": {
"id": "git.environment",
"category": "git",
"status": "ok",
"summary": "git version 2.54.0",
"details": {
".git entry": "directory",
"PATH git #1": "/usr/bin/git",
"PATH git entries": "1",
"git branch": "custom/rust-v0.142.3-startup-notes",
"git build options": "git version 2.54.0; cpu: x86_64; built from commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0; sizeof-long: 8; sizeof-size_t: 8; shell-path: /bin/sh; rust: enabled; gettext: enabled; libcurl: 8.19.0; OpenSSL: OpenSSL 3.6.2 7 Apr 2026; zlib-ng: 2.3.3; SHA-1: SHA1_DC; SHA-256: SHA256_BLK; default-ref-format: files; default-hash: sha1",
"git exec path": "/usr/lib/git-core",
"git version": "git version 2.54.0",
"repo detected": "true",
"repo root": "/home/codex/codex-src.git",
"selected git": "/usr/bin/git"
},
"remediation": null,
"durationMs": 70
},
"installation": {
"id": "installation",
"category": "install",
"status": "ok",
"summary": "installation looks consistent",
"details": {
"PATH codex #1": "/home/codex/.local/bin/codex",
"current executable": "/home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
"install context": "npm (package /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
"managed by bun": "false",
"managed by npm": "true",
"managed package root": "/home/codex/.local/lib/node_modules/@openai/codex",
"npm update target": "/home/codex/.local/lib/node_modules/@openai/codex"
},
"remediation": null,
"durationMs": 329
},
"mcp.config": {
"id": "mcp.config",
"category": "mcp",
"status": "ok",
"summary": "no MCP servers configured",
"details": {},
"remediation": null,
"durationMs": 0
},
"network.env": {
"id": "network.env",
"category": "network",
"status": "ok",
"summary": "network-related environment looks readable",
"details": {
"proxy env vars": "none"
},
"remediation": null,
"durationMs": 0
},
"network.provider_reachability": {
"id": "network.provider_reachability",
"category": "reachability",
"status": "ok",
"summary": "active provider endpoints are reachable over HTTP",
"details": {
"ChatGPT base URL": "https://chatgpt.com/backend-api/ reachable (HTTP 404)",
"reachability mode": "ChatGPT auth"
},
"remediation": null,
"durationMs": 218
},
"network.websocket_reachability": {
"id": "network.websocket_reachability",
"category": "websocket",
"status": "ok",
"summary": "Responses WebSocket handshake succeeded",
"details": {
"DNS": "2 IPv4, 2 IPv6, first IPv4",
"auth mode": "chatgpt",
"connect timeout": "15000 ms",
"endpoint": "wss://chatgpt.com/backend-api/<redacted>",
"handshake result": "HTTP 101 Switching Protocols",
"model provider": "openai",
"models etag present": "true",
"provider name": "OpenAI",
"proxy env vars": "none",
"reasoning header": "false",
"server model present": "false",
"supports websockets": "true",
"wire API": "responses"
},
"remediation": null,
"durationMs": 731
},
"runtime.provenance": {
"id": "runtime.provenance",
"category": "runtime",
"status": "ok",
"summary": "running npm on linux-x86_64",
"details": {
"commit": "unknown",
"current executable": "/home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
"install method": "npm (package /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
"platform": "linux-x86_64",
"version": "0.142.3"
},
"remediation": null,
"durationMs": 0
},
"runtime.search": {
"id": "runtime.search",
"category": "search",
"status": "ok",
"summary": "search is OK (bundled)",
"details": {
"search command": "/home/codex/.local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path/rg",
"search command readiness": "file exists",
"search provider": "bundled"
},
"remediation": null,
"durationMs": 0
},
"sandbox.helpers": {
"id": "sandbox.helpers",
"category": "sandbox",
"status": "ok",
"summary": "sandbox configuration is readable",
"details": {
"approval policy": "Never",
"codex-linux-sandbox helper": "/home/codex/.codex/tmp/arg0/codex-arg0ek4CrK/codex-linux-sandbox",
"execve wrapper helper": "/home/codex/.codex/tmp/arg0/codex-arg0ek4CrK/codex-execve-wrapper",
"filesystem sandbox": "unrestricted",
"network sandbox": "enabled"
},
"remediation": null,
"durationMs": 0
},
"state.paths": {
"id": "state.paths",
"category": "state",
"status": "ok",
"summary": "state paths and databases are inspectable",
"details": {
"CODEX_HOME": "/home/codex/.codex (dir)",
"active rollout files": "803 files, 304587990 total bytes, 379312 average bytes",
"archived rollout files": "0 files, 0 total bytes, 0 average bytes",
"goals DB": "/home/codex/.codex/goals_1.sqlite (file)",
"goals DB integrity": "ok",
"log DB": "/home/codex/.codex/logs_2.sqlite (file)",
"log DB integrity": "ok",
"log dir": "/home/codex/.codex/log (dir)",
"memories DB": "/home/codex/.codex/memories_1.sqlite (file)",
"memories DB integrity": "ok",
"sqlite home": "/home/codex/.codex (dir)",
"state DB": "/home/codex/.codex/state_5.sqlite (file)",
"state DB integrity": "ok"
},
"remediation": null,
"durationMs": 2755
},
"state.rollout_db_parity": {
"id": "state.rollout_db_parity",
"category": "threads",
"status": "warning",
"summary": "rollout files and state DB thread inventory differ",
"details": {
"default model provider": "openai",
"rollout DB active files": "803",
"rollout DB active rows": "582",
"rollout DB archive mismatches": "0",
"rollout DB archived files": "0",
"rollout DB archived rows": "0",
"rollout DB duplicate DB paths": "0",
"rollout DB duplicate rollout thread ids": "0",
"rollout DB malformed file names": "0",
"rollout DB missing active rows": "221",
"rollout DB missing active sample": [
"/home/codex/.codex/sessions/2026/06/18/rollout-2026-06-18T00-14-39-019ed8f0-2cd5-7090-80c4-73a86a9dfd99.jsonl",
"/home/codex/.codex/sessions/2026/06/18/rollout-2026-06-18T00-15-10-019ed8f0-a7bb-70b1-bfd8-a82685950f87.jsonl",
"/home/codex/.codex/sessions/2026/06/18/rollout-2026-06-18T00-15-52-019ed8f1-4966-7690-a394-bb081dc76a09.jsonl",
"/home/codex/.codex/sessions/2026/06/18/rollout-2026-06-18T01-03-22-019ed91c-c7e4-7c92-a56f-8f60269f91ea.jsonl",
"/home/codex/.codex/sessions/2026/06/18/rollout-2026-06-18T01-03-22-019ed91c-c89f-76c3-803b-ad7fa7cc621c.jsonl"
],
"rollout DB missing archived rows": "0",
"rollout DB model providers": "openai=579, openai_http=3",
"rollout DB rows": "582",
"rollout DB scan cap reached": "false",
"rollout DB scan errors": "0",
"rollout DB sources": "subagent:thread_spawn=380, cli=164, exec=38",
"rollout DB stale rows": "0"
},
"issues": [
{
"severity": "warning",
"cause": "rollout files are missing from the state DB",
"measured": "221 active, 0 archived",
"expected": "every rollout file has a matching threads row",
"remedy": null,
"fields": []
}
],
"remediation": null,
"durationMs": 13400
},
"system.environment": {
"id": "system.environment",
"category": "system",
"status": "ok",
"summary": "OS language C",
"details": {
"EDITOR": "not set",
"GH_PAGER": "set",
"GIT_PAGER": "set",
"LANG": "C.UTF-8",
"LC_ALL": "C.UTF-8",
"LC_CTYPE": "C.UTF-8",
"PAGER": "set",
"VISUAL": "not set",
"os": "Arch Linux [64-bit]",
"os language": "C",
"os type": "Arch Linux",
"os version": "Unknown"
},
"remediation": null,
"durationMs": 5
},
"terminal.env": {
"id": "terminal.env",
"category": "terminal",
"status": "ok",
"summary": "terminal metadata was detected",
"details": {
"COLORTERM": "present",
"DISPLAY": "present",
"NO_COLOR": "1",
"SSH_CLIENT": "present",
"SSH_CONNECTION": "present",
"SSH_TTY": "present",
"TERM": "st-256color",
"color output": "disabled (NO_COLOR)",
"effective locale": "C.UTF-8",
"multiplexer": "tmux 3.6b",
"stderr is terminal": "false",
"stdin is terminal": "false",
"stdout is terminal": "false",
"terminal": "unknown",
"terminal size": "80x24",
"tmux allow-passthrough": "off",
"tmux client termname": "st-256color",
"tmux extended-keys": "off",
"tmux focus-events": "off",
"tmux set-clipboard": "external",
"tmux xterm-keys": "on"
},
"remediation": null,
"durationMs": 91
},
"terminal.title": {
"id": "terminal.title",
"category": "title",
"status": "ok",
"summary": "terminal title default",
"details": {
"terminal title activity": "true",
"terminal title items": "activity, project-name",
"terminal title project source": "git repo root",
"terminal title project value": "codex-src.git",
"terminal title source": "default"
},
"remediation": null,
"durationMs": 0
},
"updates.status": {
"id": "updates.status",
"category": "updates",
"status": "ok",
"summary": "update configuration is locally consistent",
"details": {
"cached latest version": "0.142.3",
"check for update on startup": "true",
"last checked at": "2026-06-28T22:28:07.701104382Z",
"latest version": "0.142.3",
"latest version status": "current version is not older",
"npm update target": "/home/codex/.local/lib/node_modules/@openai/codex",
"update action": "npm install -g @openai/codex",
"version cache": "/home/codex/.codex/version.json"
},
"remediation": null,
"durationMs": 567
}
}
}
</details>
What issue are you seeing?
Starting codex sometimes takes a long time before the TUI reaches a usable
prompt. On this VM, the delay lines up with heavy disk activity; the disk heads
are audibly moving while startup is stuck.
I expected some slowness because this VM is currently on spinning storage. What
surprised me is that the delay happens before the prompt is usable, and it seems
to be caused by Codex's own local state rather than by scanning the source repo.
I am filing this as a current CLI/TUI startup issue, not as a broad SSD-write
report and not as a Desktop-only app-server launch failure. There are related
issues listed below, but this case is on the current latest CLI release,0.142.3, and the symptom is intermittent pre-prompt latency in the terminal
TUI.
The strongest evidence points to the local SQLite log database under ~/.codex.
At the time of investigation, these files were very large:
~/.codex/logs_2.sqlite:1,155,510,272bytes~/.codex/logs_2.sqlite-wal:603,604,752bytes~/.codex/logs_2.sqlite-shm:1,179,648bytes
The logs table had:
232,206rows99distinctprocess_uuidvalues278distinctthread_idvalues
There were also many long-lived codex processes still running. Manual/proc/*/fd inspection showed those processes holding open file descriptors for
the same log database, WAL, and SHM files:
/home/codex/.codex/logs_2.sqlite/home/codex/.codex/logs_2.sqlite-wal/home/codex/.codex/logs_2.sqlite-shm
Simple SQLite inspection of this database was slow on the machine. A
metadata/count query took about 8.35s. A broader read-only aggregate was still
running after about 90s, so I interrupted it.
This does not look like database corruption. codex doctor reported log DB
integrity as ok.
What steps can reproduce the bug?
I do not have a small clean repro yet, but this is the state that reproduced the
issue on my machine:
- Use Codex CLI
0.142.3. - Use a machine where disk seek latency is noticeable. My case is a VM backed by
spinning/platter disks.
- Keep multiple Codex TUI sessions open over time.
- Let
~/.codex/logs_2.sqliteand especially~/.codex/logs_2.sqlite-walgrow
large.
- Start a new
codexsession. - Startup can take a long time before the TUI reaches the prompt, with heavy
disk activity.
Diagnostics I ran:
codex --versioncodex doctor --jsondu -xhd2 ~/.codex 2>/dev/null | sort -hfind ~/.codex -maxdepth 4 -type f \( -name '*.sqlite' -o -name '*.sqlite-wal' -o -name '*.sqlite-shm' \) -printf '%s %p\n'sqlite3 ~/.codex/logs_2.sqlite 'PRAGMA page_count; PRAGMA page_size; SELECT COUNT(*), MIN(ts), MAX(ts) FROM logs;'sqlite3 ~/.codex/logs_2.sqlite "EXPLAIN QUERY PLAN DELETE FROM logs WHERE ts < strftime('%s','now','-10 days');"sqlite3 ~/.codex/logs_2.sqlite 'PRAGMA wal_checkpoint(PASSIVE);'ps -eo pid,ppid,stat,etime,comm,args | rg 'codex|app-server|sqlite|git'- manual
/proc/*/fdinspection, becauselsofwas not installed
The passive WAL checkpoint reported:
1|-1|-1
My understanding is that the leading 1 means the checkpoint was busy, which
would match many Codex processes having the log DB open.
What is the expected behavior?
Starting a fresh codex TUI should reach the prompt quickly even if the local
diagnostic log database has grown large.
If log cleanup or WAL checkpointing is needed, I would expect it not to block the
prompt-critical startup path. It could run after the prompt appears, run in the
background, run less often, or be surfaced through codex doctor.
I would also expect Codex to have a guardrail for total log DB/WAL growth. The
current retention behavior appears to cap logs per thread/process partition, but
the total database can still become large when there are many Codex processes and
threads.
Additional information
I looked at the rust-v0.142.3 source locally to understand what might be
happening. The relevant startup path appears to open Codex's local state runtime,
including the logs database, before the prompt is usable.
The log database startup maintenance appears to include:
- deleting old log rows by timestamp
- running
PRAGMA wal_checkpoint(PASSIVE)
The part I am less certain about is how much of that work is actually blocking
the first prompt in every case. The local behavior strongly suggests the large
log DB/WAL is the main source of the delay, but I would treat the code-path notes
as pointers for investigation rather than a complete root cause.
Code areas that looked relevant:
codex-rs/tui/src/lib.rs: TUI startup initializes local state before the prompt.codex-rs/state/src/runtime.rs: state runtime opensstate_5.sqlite,
logs_2.sqlite, goals_1.sqlite, and memories_1.sqlite.
codex-rs/state/src/runtime/logs.rs: log startup maintenance deletes old rows
and runs a passive WAL checkpoint.
codex-rs/state/src/runtime/logs.rs: log retention appears to be capped per
partition, not by total DB/WAL size.
There may also be a smaller secondary startup cost from plugin cache work:
- My config has
[plugins."github@openai-curated"] enabled = true. ~/.codex/.tmp/pluginsis about76 MB.~/.codex/.tmp/plugins-backup-*is about41 MB.- That area had about
2,299plugin checkout files at the inspected depth.
However, the log DB and WAL look like the main issue.
Possible improvements:
- Avoid running log DB retention/checkpoint maintenance synchronously before the
first prompt.
- Run log DB maintenance at most once per time window, not on every startup.
- Add a total size cap for logs, not only per-partition caps.
- Add a
codex doctorcheck for oversizedlogs_2.sqlite,
oversized logs_2.sqlite-wal, busy checkpoint status, and live Codex processes
holding the DB open.
- Consider a config or environment option to reduce SQLite log capture on
IO-constrained machines.
Related issues I found before filing, and how this report differs:
- https://github.com/openai/codex/issues/20213 is about multi-terminal CLI
freezes while sessions are already running. This report is about startup
latency before a new TUI reaches the first prompt.
- https://github.com/openai/codex/issues/27741 is about Desktop/app-server
launch failure when a large logs_2.sqlite or WAL blocks startup. This report
is CLI/TUI, not Desktop, and it did eventually reach the prompt rather than
showing a blocking app launch failure.
- https://github.com/openai/codex/issues/30105 is about Desktop startup failing
when another app-server holds logs_2.sqlite. This report also saw many live
Codex processes holding the log DB/WAL/SHM open, but the user-visible symptom
was intermittent CLI startup delay on Linux, not a native macOS Desktop error
dialog.
- https://github.com/openai/codex/issues/29237 is about a CLI crash with
trace trap. This report is not a crash report; it is a slow-start report.
- https://github.com/openai/codex/issues/28224 is about persistent SQLite log
write volume and SSD endurance. This report is not mainly about SSD wear. It
is about the same log DB/WAL work appearing to block the prompt-critical CLI
startup path.
Why this may still deserve separate triage:
- It reproduces on
codex-cli 0.142.3, which is the latest npm release I saw
before filing.
- It is specifically CLI/TUI startup latency before the first prompt, not a
Desktop dialog, an already-running session freeze, or a crash.
- The WAL is large but not multi-GB: about
604 MB, next to a1.15 GBmain
log DB.
PRAGMA wal_checkpoint(PASSIVE)reported busy, and many long-lived Codex
processes had the same log DB/WAL/SHM open.
- The machine uses slow platter-backed VM storage, which makes the startup-path
disk work easy to notice and may expose the same bug that SSD users mostly see
as background write churn or occasional launch timeout.
Short version: this looks like a startup performance problem around a shared
SQLite log database and large WAL file. It does not look like repository
scanning or database corruption.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗