Skip to content

Fix LiteDB snapshot writer detection - #49

Merged
MaxAkbar merged 1 commit into
mainfrom
codex/fix-litedb-snapshot-locking
Jul 27, 2026
Merged

Fix LiteDB snapshot writer detection#49
MaxAkbar merged 1 commit into
mainfrom
codex/fix-litedb-snapshot-locking

Conversation

@MaxAkbar

Copy link
Copy Markdown
Owner

What changed

  • open the LiteDB source snapshot with FileShare.None
  • hold that exclusive read handle for the complete byte-for-byte copy

Why

The v4.3.0 Release workflow failed its build-and-test gate on Ubuntu and macOS in LiteDbRetainedSnapshotTests.CaptureRejectsWriterOversizeEncryptionAndCollisions. Windows correctly rejected the active LiteDB writer, but Unix allowed the snapshot's FileShare.Read handle to open concurrently.

The snapshot API promises an offline/quiesced capture. Using FileShare.None makes writer detection and snapshot isolation consistent across supported operating systems.

User impact

LiteDB retained snapshots now fail closed when another process or connection has the source database open, including on Linux and macOS. Callers must close active LiteDB connections before creating the offline snapshot.

Validation

  • reproduced the original behavior under Ubuntu:
    • FileShare.Read: opened while the LiteDB writer was active
    • FileShare.None: correctly rejected while the writer was active
  • focused failing regression: 1/1 passed
  • complete CSharpDB.Migration.LiteDb.Tests suite: 22/22 passed
  • git diff --check

Release recovery

The failed v4.3.0 tag still points to the original failing commit. After this fix is merged, publish a new patch release or explicitly replace that tag before rerunning the Release workflow.

@MaxAkbar
MaxAkbar marked this pull request as ready for review July 27, 2026 15:03
@MaxAkbar
MaxAkbar merged commit 7880dad into main Jul 27, 2026
8 checks passed
@MaxAkbar
MaxAkbar deleted the codex/fix-litedb-snapshot-locking branch July 27, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants