codex icon indicating copy to clipboard operation
codex copied to clipboard

logs_2.sqlite: rmcp::service TRACE rows (~1.3 MB ListToolsResult dumps) bypass the noisy-target filter — 50-68 MB/day with a large MCP catalog

Open thejustin opened this issue 4 months ago • 4 comments

What happened

After the #28224 fixes landed (#29432, #29457, #29599 — big improvement, thank you), one high-volume emitter still reaches the persistent sqlite feedback log (logs_2.sqlite): target rmcp::service, level TRACE, whose bodies are full JSON-RPC PeerMessage dumps from app_server.request{...}:initialize:serve_inner — most notably complete ListToolsResult payloads. With a large MCP tool catalog (~180 tools/connectors in our deployment), each such row is ~1.28 MB.

Measurements (read-only queries against logs_2.sqlite)

  • codex-cli 0.144.3, linux x86_64, app-server mode over stdio (embedded in a gateway product)
  • 290 rmcp::service rows >1 MB totaling 371 MB = 49% of a 751 MB file
  • 38-54 such rows/day = 50-68 MB/day sustained
  • TRACE overall = 84% of estimated_bytes in the DB
  • The built-in ~10-day retention bounds total size, but the write volume/WAL churn remains (this is the same SSD-endurance concern as #28224)

Notes

  • RUST_LOG in the parent environment does not affect the sqlite sink (consistent with #29463) — verified by restarting the parent with RUST_LOG=info,rmcp=warn and watching >1 MB rows continue to land.

Ask

Include rmcp::service (or rmcp*) in the persistent-log noisy-target filter introduced in #29457, and/or cap per-row payload size for the sqlite sink. A documented level/off knob for the sqlite sink would also serve (the sqlite_logs_enabled escape hatch discussed in #28224 was never merged).

thejustin avatar Jul 20 '26 08:07 thejustin

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #33644

Powered by Codex Action

github-actions[bot] avatar Jul 20 '26 08:07 github-actions[bot]

Stable 0.166.0 source follow-up, separating the original filter issue from the remaining opt-out request.

I checked the strict stable tag rust-v0.166.0, peeled commit 6ff1e1ca3b30fc8b914720681fcf5fe62e95f856 (npm latest agrees). Its SQLite sink filter already limits rmcp to INFO and includes several other noisy-target filters. Therefore this comment does not claim that the original rmcp::service TRACE bypass remains reproducible on 0.166.0. I have not measured fresh stock-0.166 write amplification or hardware damage.

The separate user-control request remains relevant: I found no sqlite_logs_enabled configuration field in that fixed snapshot, and the app-server sink setup still attaches the diagnostic sink whenever its state runtime is available. This is distinct from disabling conversation/state persistence.

Our existing local 0.165 mitigation provides an explicit diagnostic-sink switch, defaults to enabled, and leaves thread/state databases, rollout history, feedback handling and ordinary file/stderr logging intact. A prior isolated A/B verification of that local patched build recorded 41 diagnostic rows when enabled and zero when disabled; both database quick_check results were ok. These are not results from stock 0.166.0, and disabling future sink writes does not reclaim existing database/WAL files.

Would a documented diagnostic-only opt-out be an acceptable upstream direction, alongside the existing default filters? Useful acceptance checks would cover the default-enabled behavior, disabled app-server and TUI sinks, and unchanged thread/state persistence. I am adding this to the existing issue rather than duplicating the original write-growth report. No raw logs, session contents, credentials or account identifiers are attached.

Additional stable-0.166 source checks (read-only, no stress test): the sink has a bounded 2,048-event queue, 512-event batches and a 10-second flush interval; full queues drop new events instead of blocking producers. Retained partition/age/occupied-page budgets are useful, but they are not a disk-write-rate cap: insertion precedes pruning, and oversized records are not rejected before insertion. See queue and filters and insert/prune.

There is also a distinct startup-availability concern, related to #27741: state-runtime initialization still propagates an unrecovered logs-DB open/migration failure after closing the state pool. A sink-write opt-out alone is not proof of nonfatal log-DB initialization. No physical SSD damage, current device endurance consumption, or fresh stock-0.166 failure rate was measured in this review.

Reference review packet (2026-10-31)

Existing patches, sanitized execution evidence and a concrete review checklist are now available. The patch exports are existing 0.165.0 reference diffs, not a completed 0.166.0 port or installer. Original and export hashes are recorded separately; all nine published files were read back and matched byte-for-byte. No private logs, sessions, databases or credentials are included.

A newer isolated A/B on the same repaired 0.165 CLI recorded 80 enabled diagnostic rows / 0 disabled, normal initialize/thread-list responses, clean exits and four quick_check=ok results. The earlier 41/0 result above remains a separate historical run. Please review whether the diagnostic-only opt-out contract and existing diff/test scope are appropriate, or identify an upstream-equivalent supported mechanism. The checklist requests source/version-specific technical feedback; no reviewer, newer build, or delivery commitment is claimed.

Campione01 avatar Oct 31 '26 04:10 Campione01

Source follow-up for Codex 0.169.0, at the peeled release commit d32063f96c2dff1dc96af839b3952abb6acfeda4.

One correction to the 0.166.0 note above: #60466 is in this stable release. For non-corruption errors opening or migrating the diagnostic database, state initialization now keeps the thread state available without a logs pool and retains the diagnostic error. Corruption still goes through the existing recovery path. The release's app-server regression also checks that thread deletion is rejected before losing saved conversation data in this condition.

This is separate from the remaining request for an explicit user setting to disable only the SQLite diagnostic sink while keeping thread state and history. The app-server attachment still has no such setting. The original rmcp::service TRACE filter issue was addressed separately; I am not reporting it as a new reproduction.

Evidence here is pinned source and the shipped regression definition, not a new local execution or a new write-volume measurement.

Campione01 avatar Nov 13 '26 18:11 Campione01

Same pattern, still present on newer builds: codex-cli 0.166.0 (interactive TUI connected to the shared app-server) and app-server daemon 0.169.0 (codex app-server --listen unix://), linux x86_64, 9 MCP servers configured (user plus project config).

Read-only measurements, 2026-11-14:

  • Write volume: one TUI process wrote 33 GB (/proc/<pid>/io write_bytes) in 2.8 h. The only regular files it held open were logs_2.sqlite, -wal and -shm. The daemon wrote 0.72 GB in one active minute, with idle minutes at about 0.
  • Retention is minutes, not days: logs_2.sqlite held only about 50 minutes of rows (13k rows, max(id) about 11.7 M), so nearly all of that volume is insert-and-prune churn, with the WAL at about 350 MB.
  • Top targets by body bytes over 10 min: rmcp::service (176 KB), feedback_tags (154 KB), codex_http_client::client (77 KB), codex_core::stream_events_utils (56 KB), codex_tui::chatwidget::protocol_requests (53 KB, DEBUG, about 70 KB per row).
  • Effect beyond SSD wear: on a VM whose disk sits on a shared HDD-backed pool, the disk ran about 1,000 small writes/s at about 15 MB/s, with the Codex app-server as the top writer by write_bytes. Earlier, a 32-minute window in which the daemon wrote about 12 GB, mostly to thread_history_1.sqlite and its WAL, ended in a 76 s filesystem commit stall that blocked unrelated SQLite users on the same disk. So the churn is not only in logs_2.sqlite.

A separate observation from the same session, in case it is related (no child processes involved): that TUI's RSS grew from about 4.8 GB to 11.7 GB, plus 2.7 GB swapped, over about 2 h, and stayed there until it was closed. I can open a separate issue if that is unrelated to the log sink.

The ask in #43378 (make the sqlite sink's level configurable, or honour RUST_LOG) would let installs like this one turn the sink down without symlinking the database to tmpfs.

WingedGuardian avatar Nov 15 '26 00:11 WingedGuardian