Skip to content

[Bug][Windows]: cold Storage inspection blocks the proxy thread on large Codex SQLite logs #2605

Description

@stephen-drew

Client or integration

Codex App

Area

Dashboard / Storage / Log Guard

Summary

The first Storage / Log Guard inspection runs four unbounded SQLite aggregates synchronously on the OpenCodex proxy thread.

On a large Codex logs_2.sqlite, opening or refreshing Storage can therefore block routing and health responses until the aggregates finish. The current memoization removes repeated scans only while the database and WAL identity stay unchanged. It does not bound the cold scan, and an active Codex process changes the WAL and invalidates the cache.

Expected: Storage inspection must not block the proxy thread. Expensive metrics should run off-thread, be explicitly bounded, or degrade to file/schema-only metrics above a safe threshold.

Actual: readMetrics performs count(*), two GROUP BY queries and sum(estimated_bytes) synchronously. Both /api/storage and /api/storage/codex-logs call the inspection inline.

Current dev documents the same remaining gap in src/codex/log-guard/inspect.ts: memoization "bounds the repeat cost, not the first one" and the cold scan still blocks.

Reproduction

  1. Use a Codex logs_2.sqlite with hundreds of thousands of rows.
  2. Start an unmodified OpenCodex build.
  3. Open the Storage page or request GET /api/storage after the inspection cache is cold or after the WAL changes.
  4. In parallel, request /healthz or send a routed model request.
  5. Observe that the synchronous SQLite aggregates occupy the proxy thread until inspection completes.

Historic live reproduction on OpenCodex 2.26.0:

  • database: approximately 1 GB
  • rows: approximately 495,000
  • GROUP BY level: approximately 17,289 ms
  • GUI resource deadline: 30 seconds
  • filesystem scan itself: under one second across approximately 11,943 files

A local mitigation skipped expensive aggregates when the database exceeded 64 MiB while retaining file size, schema and capability inspection. After that change:

  • GET /api/storage: 628 ms, then 466 ms
  • GET /api/storage/codex-logs: 9 ms
  • GET /healthz: 200

I also ran the unmodified official 2.32.0 inspector in a separate read-only process against the current database:

  • database: 1,468,923,904 bytes
  • rows: 681,808
  • first isolated inspection: 816 ms
  • same-process memoized repeat: 0.448 ms
  • schema: compatible

The current host file cache was already warm, so 816 ms is not presented as a worst case. The earlier 17.3-second live result and the 49-second large-database measurement documented in the current source show the cold/fragmented case.

Version

2.26.0 for the historic live reproduction. The synchronous cold-scan path remains in the official 2.32.0 package and current dev source (file SHA d2c17192365cad0dae2b678456588a03ae407a61 at the time of filing).

Operating system

Windows 11 Home 25H2, OS build 26200.9168, x64.

Provider and model

Not provider-specific. The defect is in local Storage / SQLite inspection.

Logs or error output

Historic unmodified path:
logs_2.sqlite: ~1 GB
rows: ~495,000
GROUP BY level: ~17,289 ms
/api/storage GUI budget: 30,000 ms

Local bounded mitigation:
large database threshold: 67,108,864 bytes
/api/storage: 628 ms, then 466 ms
/api/storage/codex-logs: 9 ms
/healthz: 200

Official 2.32.0 inspector, separate read-only process:
databaseBytes=1468923904
totalRows=681808
firstElapsedMs=816
memoizedRepeatMs=0.448
schema=compatible

Screenshots and supporting files

No screenshot is needed. The current source comment and query implementation are visible in inspect.ts.

Redacted configuration

{
  "storageInspection": "default",
  "database": "Codex logs_2.sqlite",
  "providers": "<not relevant>"
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, private paths and personal data.

Activity

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

    bugSomething isn't workingplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions