Skip to content

fix(storage): enforce WAL hard-pressure drain before project WAL exceeds 256 MiB #798

Description

@ScriptedAlchemy

Defect

On the live operator profile at 2026-09-03T00:20:24Z (binary 0.1.0-beta.37+5de159b26), tracedecay status --runtime --json reported project shard proj_a5b3d7e3ebe14ca7 at wal_bytes=780,299,192 and aggregate wal_bytes=974,265,192, while wal_hard_limit_bytes=268,435,456. The project shard had been idle for 168,291 ms and its writer had 0 offered/admitted operations in this incarnation, so the >2.9x hard-limit state persisted beyond an active batch.

Contract contradiction

  • crates/tracedecay-store/src/runtime/operation.rs defines and caps WAL soft/hard budgets at 32/256 MiB.
  • crates/tracedecay-rusqlite-runtime/src/checkpoint/controller.rs classifies >= hard as hard pressure and retains hard_drain_required until checkpoint completion.
  • crates/tracedecay-rusqlite-runtime/src/writer/worker/mod.rs maps hard pressure to BlockGeneral.
  • crates/tracedecay-rusqlite-runtime/src/connection/mod.rs documents exceptional over-soft growth as tolerated only up to the 256 MiB hard limit and says it must not become permanent.

The live ready shard violated that contract.

Acceptance criteria

  • Attribute why the scheduled PASSIVE checkpoint/hard-drain state allowed the WAL to reach 780 MiB. Include blocker inventory and hard-pressure retry telemetry.
  • Do not raise the limit. Once hard pressure is reached, prevent further general writes and complete a bounded drain/checkpoint, or surface a typed degraded/faulted shard state naming the blocking leases instead of remaining ready.
  • Add an integration test with a held snapshot/reader plus continued writes that proves WAL growth cannot silently exceed the configured hard limit and verifies recovery to <= soft after the blocker clears.
  • Runtime status exposes the pressure/drain/blocker state whenever wal_bytes >= hard_limit_bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions