Skip to content

logs_2.sqlite-wal grows indefinitely and remains allocated after deletion because stale/suspended Codex TUI processes keep the deleted WAL open #22444

Closed

Description

@ZenulAbidin

What version of Codex CLI is running?

0.128.0

What subscription do you have?

Pro 20x

Which model were you using?

gpt-5.5 xhigh

What platform is your computer?

Ubuntu 22.04.4 LTS (Jammy Jellyfish)

What terminal emulator and version are you using (if applicable)?

Konsole 21.12.3 / tmux 3.2a

What issue are you seeing?

The shared Codex diagnostic SQLite WAL under ~/.codex repeatedly grows indefinitely, filling the root filesystem. Deleting ~/.codex/logs_2.sqlite-wal does not immediately free the disk space because older/suspended Codex TUI processes keep file descriptors open to the deleted WAL inode.

This has happened more than once on the same machine. The most recent reproduction had the following shape:

/home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
size: 740,472,217,600 bytes (~690G)
inode: 73979730

du ~/.codex no longer showed the space after the file was deleted, but df -h still showed the root filesystem as full/near-full because the deleted file was still open.

Example after deleting the visible file:

df -h /home/zenulabidin
Filesystem      Size  Used Avail Use% Mounted on
/dev/md2        3.6T  2.8T  678G  81% /

du -xsh /home/zenulabidin/.codex
501M    /home/zenulabidin/.codex

The missing space was explained by lsof +L1:

690GB 560078  codex 19u 73979730
690GB 560078  codex 16u 73979730
690GB 1164072 codex 41u 73979730
690GB 1164072 codex 24u 73979730
690GB 1164072 codex 21u 73979730
1.4GB 560078  codex 22ur 73979787
1.4GB 1164072 codex 22ur 73979787

Expanded lsof for the relevant processes:

codex 560078  ... 16u  REG 9,2 740472217600 73979730 /home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
codex 560078  ... 19u  REG 9,2 740472217600 73979730 /home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
codex 560078  ... 22ur REG 9,2   1437827072 73979787 /home/zenulabidin/.codex/logs_2.sqlite-shm (deleted)

codex 1164072 ... 21u  REG 9,2 740472217600 73979730 /home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
codex 1164072 ... 24u  REG 9,2 740472217600 73979730 /home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
codex 1164072 ... 41u  REG 9,2 740472217600 73979730 /home/zenulabidin/.codex/logs_2.sqlite-wal (deleted)
codex 1164072 ... 22ur REG 9,2   1437827072 73979787 /home/zenulabidin/.codex/logs_2.sqlite-shm (deleted)

The processes holding the deleted WAL were old/suspended TUI sessions:

PID     PPID     PGID     SID     TTY     STAT  STARTED                  CMD
560078  557398   557398   763432  pts/21  TNl   Thu May  7 05:41:24 2026 codex
1164072 1161996  1161996  763432  pts/21  TNl   Sat May  9 05:54:21 2026 codex

This also happened earlier with the same file family. In that run, ~/.codex/logs_2.sqlite-wal reached:

734,748,852,032 bytes (~685G)

and after deletion, it remained allocated until the Codex processes holding the deleted WAL exited.

What steps can reproduce the bug?

I do not have a minimal deterministic reproducer yet, but this has reproduced twice under real use:

  1. Run multiple Codex TUI sessions over several days, all sharing the default ~/.codex directory.

  2. Leave some sessions suspended/stale in tmux.

  3. Accumulate enough Codex activity that ~/.codex/logs_2.sqlite-wal grows to hundreds of GB.

  4. Delete the visible logs_2.sqlite-wal to recover disk space.

  5. Observe that du ~/.codex drops, but df -h does not recover the space.

  6. Run:

    lsof -nP +L1 | awk 'NR>1 && $7 ~ /^[0-9]+$/ && $7 > 1000000000 {print $7, $2, $1, $4, $9}' | sort -nr | head -n 40 | numfmt --field=1 --to=iec --suffix=B
  7. Observe stale/suspended Codex processes holding deleted logs_2.sqlite-wal and logs_2.sqlite-shm file descriptors open.

  8. Exit or kill the stale Codex processes. Only then does df -h recover the missing space.

What is the expected behavior?

Codex should not allow the persistent diagnostic log WAL to grow unbounded to hundreds of GB, and stale/suspended TUI sessions should not keep enormous deleted WAL files open indefinitely.

Additional information

This appears related to, but more severe than:

Activity

  1. added
    bug
    on May 13, 2026
  2. added
    agent
    CLI
    on May 13, 2026
  3. ZenulAbidin commented on May 18, 2026

    @ZenulAbidin
    Author

    This issue is also reproducible on 0.130.0

  4. zacharypig commented on May 25, 2026

    @zacharypig

    Additional reproduction case

    Environment: TencentOS (CentOS Stream 9 based), Codex installed via npm with Node v20 + v22, running on a 100GB root partition.

    What happened:

    Three long-running Codex processes (2 of them running for 12+ days via codex resume) held read locks on the WAL, preventing checkpoint:

    PID 787272  – codex resume (Node v20, running ~14h)
    PID 2608234 – codex resume 019e1a45-... (Node v22, running 12 days)
    PID 2826315 – codex (Node v22, running 12 days)
    

    The WAL grew to 11.25 GB, completely filling the 100GB root partition (ENOSPC). The database itself (logs_2.sqlite) was only 209MB with ~98K rows.

    Diagnosis:

    $ sqlite3 ~/.codex/logs_2.sqlite "PRAGMA wal_checkpoint(TRUNCATE); "
    1|186|186   # returns BUSY because readers hold locks
    
    $ fuser ~/.codex/logs_2.sqlite
    787272 2608234 2826315

    Recovery:

    After killing the two stale 12-day-old processes:

    $ kill 2608234 2826315
    $ sqlite3 ~/.codex/logs_2.sqlite "PRAGMA wal_checkpoint(TRUNCATE); "
    0|0|0       # success, WAL truncated to 0 bytes

    Root cause analysis:

    The logs table schema stores TRACE/DEBUG/INFO level telemetry with estimated_bytes column, but the real bloat is in the WAL itself — not the logical data. The WAL cannot be checkpointed while any reader holds a snapshot, and long-lived codex resume sessions never release their read transactions.

    Suggested mitigations:

    1. Periodic PRAGMA wal_checkpoint(PASSIVE) in a background timer (non-blocking, won't interfere with readers but will reclaim what it can)
    2. Set PRAGMA journal_size_limit = 100000000 (100MB cap on WAL file)
    3. Detect and warn when WAL exceeds a threshold (e.g., 1GB)
    4. Consider using PRAGMA wal_autocheckpoint = 1000 with shorter read transactions

    This is a significant issue for dev machines with limited root partition space — the WAL growth is silent and can completely lock up the system.

  5. ZenulAbidin commented on May 31, 2026

    @ZenulAbidin
    Author

    Still reproducible on 0.135.0

  6. ZenulAbidin commented on Jun 17, 2026

    @ZenulAbidin
    Author

    Still reproducible on 0.140.0, with the additional side effect of deleting files and folders on your filesystem if /goal mode is in use.

  7. liuminsheng3 commented on Jun 17, 2026

    @liuminsheng3

    One extra recovery distinction that may help here: this has two different disk-full states that look similar but need different handling.

    1. Visible WAL bloat: ~/.codex/logs_2.sqlite-wal is still present and large because checkpointing cannot truncate it.
    2. Deleted-open-inode bloat: the visible WAL was removed, so du ~/.codex drops, but stale Codex processes still hold deleted logs_2.sqlite-wal / logs_2.sqlite-shm descriptors, so df does not recover.

    For users currently stuck in the second state, I would capture this before deleting anything else:

    du -xsh "$HOME/.codex" 2>/dev/null
    df -h "$HOME"
    lsof -nP +L1 2>/dev/null | awk 'NR>1 && $7 ~ /^[0-9]+$/ && $7 > 1000000000 {print $7, $2, $1, $4, $9}' | sort -nr | head -40 | numfmt --field=1 --to=iec --suffix=B
    fuser "$HOME/.codex/logs_2.sqlite" 2>/dev/null

    Then recovery order:

    # 1. Stop starting new Codex sessions.
    # 2. Cleanly exit stale tmux/TUI sessions if possible.
    # 3. If needed, terminate only stale PIDs still holding deleted WAL/SHM descriptors.
    # 4. After readers are gone:
    sqlite3 "$HOME/.codex/logs_2.sqlite" "PRAGMA wal_checkpoint(TRUNCATE);"
    # 5. Verify:
    df -h "$HOME"
    lsof -nP +L1 | grep -E 'codex|logs_2.sqlite' || true

    For a product-side guard, I would separate warnings for:

    • WAL file exceeds a threshold while still visible
    • checkpoint returns BUSY for too long
    • stale Codex processes have read transactions older than N hours/days
    • deleted WAL/SHM descriptors are still open and exceed a threshold

    I wrote the full Linux deleted-WAL runbook here in case it helps users recover without wiping ~/.codex: https://site-iota-ebon-80.vercel.app/codex-sqlite-wal-disk-full-linux?utm_source=github&utm_medium=issue-comment&utm_campaign=codex-sqlite-wal-enospc&utm_term=logs-2-sqlite-wal-deleted-open-inode&utm_content=openai-codex-22444

  8. leventov commented on Jun 18, 2026

    @leventov

    @ZenulAbidin how do you address this issue, at least temporarily?

  9. ZenulAbidin commented on Jun 18, 2026

    @ZenulAbidin
    Author

    @leventov I posted a workaround here #28224 (comment)

  10. Necmttn commented on Jun 21, 2026

    @Necmttn

    This needs a lifecycle guard around the shared SQLite WAL, not only a cleanup note.

    Codex could emit a health warning when WAL bytes exceed a threshold and include the owning PIDs, open fd paths, db path, last checkpoint time, and safe restart guidance. Long-running resume processes should also checkpoint or rotate predictably instead of leaving deleted WAL inodes allocated.


    Generated with ax.

  11. ZenulAbidin commented on Jun 23, 2026

    @ZenulAbidin
    Author

    Closing as the associated issue #28224 has been resolved

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

    CLIagentbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions