#3043·LiteDB

Legacy WAL ownership is ambiguous for headerless transactions and same-seed database copies

Author: JKamskerCreated Sep 28, 2026Updated Sep 28, 2026

Summary

This is a pre-existing legacy-format limitation, not introduced by #3027.

#3027 hardens legacy WAL recovery substantially: it rejects converted/torn/foreign WALs when page type, bounds, trailer, or committed-header identity proves they do not belong to the data file.

Two ambiguous cases remain because the 5.x WAL does not always carry enough identity to prove ownership:

  1. a foreign legacy WAL whose committed transaction contains no header page (for example a transaction that allocated no page) and stays within valid page bounds;
  2. a WAL from another copy of the same seed database with the same creation time.

In those cases the current engine can still replay the WAL as if it belongs to the data file, as 5.0.21 did.

Why this matters

Recovery should not silently apply mutations from another database file merely because the legacy format lacks a decisive identity field.

At the same time, rejecting every legacy WAL without a committed header may reject valid 5.0.21 crash images, so this needs an explicit compatibility/safety decision rather than another heuristic.

Scope

Track this separately from #3027. #3027 should fix regressions it introduces and the concrete legacy cases it can discriminate safely; it should not become an unbounded redesign of the released v5 WAL format.

This is closely related to the broader ownership/WAL-identity work in #2923.

Desired outcome

Define and test a bounded policy for ambiguous legacy WAL ownership, for example one of:

  • prove ownership using additional invariant(s) available in released files;
  • reject ambiguous WALs without mutating either file;
  • explicitly retain the compatibility behavior with documented risk, if no safe discriminator exists.

Whatever policy is selected, add exact-file preservation tests for rejection and real 5.0.21 positive controls so valid legacy recovery is not accidentally lost.

Related: #2923, #3027.