#3049·LiteDB

Define crash-safe rebuild behavior when storage cannot sync

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

Summary

Track the rebuild residual documented in #3027 separately:

A rebuild on storage that cannot sync installs its replacement without a power-loss guarantee; the original files remain under -backup names.

This should not make #3027 unbounded, but the rebuild protocol needs an explicit contract for storage where the file and/or containing directory cannot provide the required durability barriers.

Distinction from #3011

#3011 tracks missing directory syncs around rebuild renames/marker operations on Unix when those durability primitives are available.

This issue is specifically about the case where the required sync operation is unsupported/unavailable or cannot be completed.

Questions to settle

  • May rebuild publish the replacement at all when it cannot establish durability?
  • Which file is authoritative after process death/power loss at every install step?
  • Is keeping -backup sufficient for automatic deterministic recovery, or only for manual salvage?
  • How should Direct and Shared mode report/refuse the operation?
  • What happens if file sync works but directory sync does not, or vice versa?

Preferred safety contract

Unless a stronger recoverable protocol is demonstrated, fail closed before publishing a replacement that cannot be made durable. Keep the original database authoritative and leave actionable diagnostics.

Required evidence

Deterministic interruption tests around:

  • rebuilt-file final sync,
  • recovery-marker creation/publication,
  • original → backup rename,
  • rebuilt → original rename,
  • marker removal,
  • cleanup,

with sync unsupported/failing at each relevant boundary.

Cold reopen must produce one explicitly allowed state with no silent loss or ambiguous generation selection.

Scope

Separate follow-up from #3027 unless bisection shows #3027 introduced the behavior.

Related: #3011, #3027, #2988, #3034.