Skip to content

storage: a second in-process LMDB handle can lose search postings during a rebuild #1111

Open

Description

@chappie-daemon

Two LmdbBackend handles over the same path share one heed Env (the OPENED_ENV cache), so a second handle is reachable. LmdbBackend::open takes the per-path rebuild lock, but writers do not. A write committed by a second handle after the rebuild's read snapshot and before its clear has its postings swept by the clear, and the rebuild then writes the marker, so later opens skip rebuilding and the index is missing those postings — silently, because the body verdict masks a missing key only as a missed match.

Found by the round-2 code lens of job 028 ([INFERENCE], no repro yet). ADR 0012 D9 records the contract — one handle per store per process, and a rebuild must not overlap writes — and names what closing it properly means: the rebuild taking the write path's own lock, or indexing from a snapshot later writers cannot invalidate.

What decides it: a failing test first — open a store, start a stale-marker rebuild, commit a write through a second handle inside that window, then assert the postings for the new event exist and the marker is honest. Today that test should fail.

Not reachable in any shipped shape: nothing in production constructs LmdbBackend yet.

Activity

  1. added
    bugSomething isn't working
    rewritenostream 4.0 Rust/LMDB rewrite
    rustRust implementation work
    factoryBuilt by the software factory
    on Nov 11, 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

    bugSomething isn't workingfactoryBuilt by the software factoryrewritenostream 4.0 Rust/LMDB rewriterustRust implementation work

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions