Add startup WAL truncation and optional checkpoint gaps #122

Merged
Collaborator

Attempt a writer-only startup checkpoint with a two-second timeout, preserve checkpoint counts in JSON logs, and continue when busy. Add validated, disabled-by-default quiet gaps shared across accounts, backfill batches, message embedding, and attachment embedding.

Report WAL bytes in mail_status, print checkpoint settings in mailmind check, and document Litestream limitations in deployment comments and example configuration.

Validation: make check passed with 794 tests passed and 8 skipped, including lint, typing, and audit. Source distribution and wheel builds passed.

Closes #118
Co-Authored-By: gpt-6.1-sol noreply@openai.com

Attempt a writer-only startup checkpoint with a two-second timeout, preserve checkpoint counts in JSON logs, and continue when busy. Add validated, disabled-by-default quiet gaps shared across accounts, backfill batches, message embedding, and attachment embedding. Report WAL bytes in mail_status, print checkpoint settings in mailmind check, and document Litestream limitations in deployment comments and example configuration. Validation: make check passed with 794 tests passed and 8 skipped, including lint, typing, and audit. Source distribution and wheel builds passed. Closes #118 Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
Attempt a writer-only startup checkpoint with a two-second timeout, preserve checkpoint counts in JSON logs, and continue when busy. Add validated, disabled-by-default quiet gaps shared across accounts, backfill batches, message embedding, and attachment embedding.

Report WAL bytes in mail_status, print checkpoint settings in mailmind check, and document Litestream limitations in deployment comments and example configuration.

Validation: make check passed with 794 tests passed and 8 skipped, including lint, typing, and audit. Source distribution and wheel builds passed.

Closes #118
Co-Authored-By: gpt-6.1-sol <noreply@openai.com>

This was generated by AI during the #118 architect gate.

Litestream reproduction (spec verification step)

Run on the operator's host on 2026-11-02 in the 0.8.1 image with Litestream 0.3.13 (file replica, debug logging), the #91 writer at 100-row commits for 90 s, 30,000-row base, WAL truncated to 0 before each phase. The gap is the mechanism Store.quiet applies: after every 20 commits the writer holds no transaction and issues no write for 2 s. The writer is the only writer in the container, so this is the same condition the lock gives the sync process.

Phase Commits WAL high-water WAL at end Litestream checkpoints
no gap 573 797 MB 797 MB 1 RESTART ok, 23 RESTART busy
gap 2 s every 20 360 (18 gaps) 39.7 MB 39.7 MB PASSIVE and RESTART land during the gaps

Gap high-water is 0.05 times the no-gap high-water. The acceptance bound is 0.2. Pass.

WAL size every 10 s, MB. No gap: 0, 89, 178, 269, 360, 451, 536, 624, 713, 797. Gap: 0, 27, 27, 37, 37, 37, 37, 40, 40, 40.

Cost of the gap at these settings: 36 s of 90 s with no writes, so throughput fell to 360 commits from 573. Writer latency was unchanged (p50 133 ms against 125 ms, max 1.0 s against 3.0 s).

Not covered here: the startup truncate on the live pod. Check the sync container's startup checkpoint log line shows busy: false after the next rollout.

> *This was generated by AI during the #118 architect gate.* ## Litestream reproduction (spec verification step) Run on the operator's host on 2026-11-02 in the `0.8.1` image with Litestream 0.3.13 (file replica, debug logging), the #91 writer at 100-row commits for 90 s, 30,000-row base, WAL truncated to 0 before each phase. The gap is the mechanism `Store.quiet` applies: after every 20 commits the writer holds no transaction and issues no write for 2 s. The writer is the only writer in the container, so this is the same condition the lock gives the sync process. | Phase | Commits | WAL high-water | WAL at end | Litestream checkpoints | |---|---:|---:|---:|---| | no gap | 573 | 797 MB | 797 MB | 1 RESTART ok, 23 RESTART busy | | gap 2 s every 20 | 360 (18 gaps) | 39.7 MB | 39.7 MB | PASSIVE and RESTART land during the gaps | Gap high-water is 0.05 times the no-gap high-water. The acceptance bound is 0.2. Pass. WAL size every 10 s, MB. No gap: 0, 89, 178, 269, 360, 451, 536, 624, 713, 797. Gap: 0, 27, 27, 37, 37, 37, 37, 40, 40, 40. Cost of the gap at these settings: 36 s of 90 s with no writes, so throughput fell to 360 commits from 573. Writer latency was unchanged (p50 133 ms against 125 ms, max 1.0 s against 3.0 s). Not covered here: the startup truncate on the live pod. Check the sync container's `startup checkpoint` log line shows `busy: false` after the next rollout.
Sign in to join this conversation.
No description provided.