Skip to content

fix: stop witness start double-opening the reg LMDB env (1.3 line) - #11

Closed
dhh1128 wants to merge 1 commit into
bug-238-witness-logging-1.3from
fix/lmdb-reopen-double-open
Closed

fix: stop witness start double-opening the reg LMDB env (1.3 line)#11
dhh1128 wants to merge 1 commit into
bug-238-witness-logging-1.3from
fix/lmdb-reopen-double-open

Conversation

@dhh1128

@dhh1128 dhh1128 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Problem

On this 1.3 line, kli witness start aborts at "Starting witness..." with:

lmdb.Error: The environment '/home/witness/.keri/reg/witness' is already open in this process.

Two independent code paths open the same reg (credential registry) LMDB path in one process, which LMDB forbids:

  1. QueryEnd.__init__ created its own Reger(name=hab.name, …) on the same reg path as setupWitness's shared reger — a second env handle for the same path.
  2. LMDBer.reopen() called lmdb.open() without first closing an already-open env, so reopening the reg via its BaserDoer opened a second handle on the same path.

Fix (both are backports of what keri main already does)

  1. Thread the shared reger into QueryEndQueryEnd(hab, reger) reuses it instead of opening a second env (setupWitness now passes reger=reger).
  2. Make LMDBer.reopen() idempotent — close self.env (best-effort) and null it before re-opening.

Validation

Built a witness image from this branch (keri @ this fix + hio 0.7.19 + Python 3.14.5) and ran it:

  • Before: container aborts at Starting witness... → the lmdb.Error above; never becomes ready.
  • After: boots cleanly — Starting witness...Witness witness : BBDzeCI8m9Ls3OBw_LTOnJSEUyWXMD-Xggp4ufqeAE_9, and GET /oobi/<AID>/controller200.

Verified end-to-end through the witness-qualifier black-box acceptance harness (full C1–C19 + Tier-P bar).

Found while evaluating the keri 1.3 line as a deployable witness closure — it was the only thing blocking it.

`kli witness start` on this 1.3 line aborts at "Starting witness..." with
`lmdb.Error: The environment '.../reg/witness' is already open in this process`.
Two independent code paths open the same reg (credential registry) LMDB path in
one process, which LMDB forbids:

1. QueryEnd.__init__ created its OWN `Reger(name=hab.name, …)` on the same reg
   path as setupWitness's shared reger. Fix: thread the shared reger into
   QueryEnd (QueryEnd(hab, reger)) and reuse it, exactly as keri main does.

2. LMDBer.reopen() called lmdb.open() without first closing an already-open
   env, so reopening the reg via its BaserDoer opened a second handle on the
   same path. Fix: close self.env (best-effort) and null it before re-opening,
   making reopen() idempotent — again matching keri main.

Both are backports of the corresponding keri-main changes. With them the witness
boots cleanly and the closure qualifies through the witness-qualifier bar.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Hardman <daniel.hardman@gmail.com>
@dhh1128

dhh1128 commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Superseded by WebOfTrust#1536 — the fix belongs upstream against WebOfTrust/keripy's v1.3.5 branch (from a personal fork), not the provenant-dev fork. Closing here.

@dhh1128 dhh1128 closed this Jul 22, 2026
@dhh1128
dhh1128 deleted the fix/lmdb-reopen-double-open branch July 22, 2026 20:19
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.

1 participant