Skip to content

Reclaim unused SQLite log database pages in the background - #49069

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/8421f87b0aeef6540eda5690c84216906673c72e
Sep 28, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/8421f87b0aeef6540eda5690c84216906673c72e

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Reclaim unused SQLite log database pages in the background

Why

Deleting logs leaves free SQLite pages available for reuse without shrinking the database file. Reclaim excess free space while preserving a reserve for future writes.

What changed

  • Start a background incremental-vacuum worker with StateRuntime, enabling reclamation only for the logs database. Use a per-home file lock to select one worker and wait for it to finish during shutdown.
  • Reclaim pages when at least 64 MiB and 25% of the database are free, preserving a reserve of at least 16 MiB or 10% of the database.
  • Use short transactions with page and cooperative time budgets, defer work on contention, and reduce batch sizes with exponential backoff when interrupted passes make no progress.
  • Record reclamation counts, durations, and reclaimed pages in telemetry.

Testing

Add a regression test that interrupts a vacuum commit, verifies foreground writes can resume without data loss, then confirms a resumed pass shrinks the database and passes PRAGMA integrity_check.

## Why

Deleting logs leaves free SQLite pages available for reuse without shrinking the database file. Reclaim excess free space while preserving a reserve for future writes.

## What changed

- Start a background incremental-vacuum worker with `StateRuntime`, enabling reclamation only for the logs database. Use a per-home file lock to select one worker and wait for it to finish during shutdown.
- Reclaim pages when at least 64 MiB and 25% of the database are free, preserving a reserve of at least 16 MiB or 10% of the database.
- Use short transactions with page and cooperative time budgets, defer work on contention, and reduce batch sizes with exponential backoff when interrupted passes make no progress.
- Record reclamation counts, durations, and reclaimed pages in telemetry.

## Testing

Add a regression test that interrupts a vacuum commit, verifies foreground writes can resume without data loss, then confirms a resumed pass shrinks the database and passes `PRAGMA integrity_check`.

GitOrigin-RevId: 8421f87b0aeef6540eda5690c84216906673c72e
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/8421f87b0aeef6540eda5690c84216906673c72e branch from f9ee87b to 33a0f76 Compare September 28, 2026 20:19
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@copyberry
copyberry Bot merged commit 33a0f76 into main Sep 28, 2026
1 check failed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/8421f87b0aeef6540eda5690c84216906673c72e branch September 28, 2026 20:19
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 28, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — 33a0f766 Deployed Sep 28, 2026 by brentjreynolds via Identify potential duplicates (all issues) #49554
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants