Skip to content

Multi-process WAL catch-up in BeginTransaction reads the WAL without the SHM writer lock #199

Open

Description

@CaffeinatedCoder

Found by @mrdevrobot while reviewing #169; plausible, not reproduced yet. The code references are to the #169 branch (b721fee).

The catch-up in StorageEngine.BeginTransaction (through TryCatchUpWithSharedWal) reads the shared WAL file without the SHM writer lock. If another process truncates the WAL and appends new records while the read is in progress, the replay can parse the new bytes at the old offsets. It can then misread records, or skip records and still move the bookmark forward.

Possible fix

A WAL generation counter in the SHM, incremented on every truncation. Read it before and after the replay, and throw the result away if it changed. This is the counter suggested in #197, and it would cover both problems.

Activity

  1. added
    bugSomething isn't working
    area/multi-processAllowMultiProcessAccess, shared WAL, SHM
    severity/highWrong results, crash or failed writes in a realistic scenario
    priority/P1Must be in the next minor release
    and removed on Oct 15, 2026
  2. added this to the 5.3.0 milestone on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/multi-processAllowMultiProcessAccess, shared WAL, SHMbugSomething isn't workingpackage/coreAffects BLite.Corepriority/P1Must be in the next minor releaseseverity/highWrong results, crash or failed writes in a realistic scenario

    Type

    No type

    Projects

    • Status
      Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions