#3048·LiteDB

Durable commits after reopen must not depend on an unproven WAL prefix

Author: JKamskerCreated Sep 29, 2026Updated Sep 29, 2026

Summary

Track the fsyncgate residual documented in #3027 separately from that PR.

If a WAL sync fails after some/all transaction bytes have reached the OS/storage stack, the failed transaction correctly has outcome Unknown. A later process can reopen the database while those bytes are still visible, recover that transaction, and then append new commits.

The safety question is whether a later commit can be acknowledged as durable while still depending on WAL prefix bytes whose durability was never successfully established. If power is then lost before checkpoint, recovery may lose not only the original outcome-unknown transaction but also later commits that were reported durable.

This is materially different from merely allowing an Unknown commit to disappear.

Why this is separate from #3027

#3027 explicitly documents this as a residual. Its introducing revision has not been established. Do not expand #3027 to fix it unless a bisect/reproducer shows that #3027 introduced the behavior.

Required investigation

Build a deterministic scenario/fault model for:

  1. Commit A writes a complete confirmation frame.
  2. WAL sync fails after the bytes become visible but before durability is established; A returns Unknown.
  3. The engine that observed the failure writes nothing further.
  4. A fresh process/connection opens the same files before the uncertain prefix disappears and recovers A.
  5. It commits B with durable commits enabled and receives success.
  6. Power loss occurs before checkpoint.
  7. Cold reopen verifies the exact durable state.

The model must be able to represent a failed sync that leaves bytes readable/clean from the caller's point of view but not actually durable; a simple "last successful sync image" model may be insufficient.

Acceptance

One of:

  • prove B's successful durability barrier necessarily establishes durability of every WAL byte B depends on; add a regression test for that invariant, or
  • change recovery/admission/publication so later durable commits cannot depend on an unproven prefix, or
  • fail closed before acknowledging B.

In all cases, the contract remains:

An outcome-unknown commit may disappear after power loss. A later commit acknowledged as durable must not disappear because it depended on that unknown commit's unproven storage state.

Also establish the first bad revision / whether this is pre-existing on dev, and record the release disposition in #2623.

Related: #3027, #3034.