Skip to content

GH-5807 Recover LMDB readers safely when maxreaders is full#5806

Merged
hmottestad merged 4 commits intomainfrom
GH-0000-lmdb-readers-full-timeout
May 2, 2026
Merged

GH-5807 Recover LMDB readers safely when maxreaders is full#5806
hmottestad merged 4 commits intomainfrom
GH-0000-lmdb-readers-full-timeout

Conversation

@hmottestad
Copy link
Copy Markdown
Contributor

@hmottestad hmottestad commented May 1, 2026

GitHub issue resolved: #5807

Briefly describe the changes proposed in this PR:

Fixes #5807.

  • Added a Spring Boot RDF4J Server regression test that reproduces LMDB read handle exhaustion after many timed-out queries.
  • Made LMDB read transaction acquisition recover from MDB_READERS_FULL by closing pooled reset-mode readers, checking for dead LMDB readers, waiting briefly for tracked reader owners, and retrying.
  • Preserved inactive/reset tracked read transactions until their owner closes them; inactive means the LMDB txn was reset, not that the Java owner is gone.
  • Added focused TxnManager regressions proving reader-full recovery and manager reset do not abort a tracked inactive transaction that is still owned by a live caller.
  • Added a ValueStore retry path that closes stale thread-local read transactions before retrying after reader exhaustion.

Root cause: timed-out server query work could leave LMDB read transactions occupying reader slots. Once LMDB reached maxreaders, subsequent reads failed with MDB_READERS_FULL. Reader recovery must reclaim only handles that are safe to own, such as pooled reset-mode readers or dead process/thread readers reported by LMDB; aborting a tracked inactive transaction can invalidate a live caller's handle.

Verification:

python3 .codex/skills/mvnf/scripts/mvnf.py --module core/sail/lmdb TxnManagerTest --retain-logs --stream
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
[mvnf] Tests passed.
python3 .codex/skills/mvnf/scripts/mvnf.py --module tools/server-boot LmdbTimedOutQueryReadHandleTest#lmdbRepositoryStillAcceptsQueriesAfterManyTimedOutServerQueries --retain-logs --stream
LMDB timeout reproducer stats: timeouts=22, readerHandleFailures=0, failureSamples=[]
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
[mvnf] Tests passed.
python3 .codex/skills/mvnf/scripts/mvnf.py core/sail/lmdb --retain-logs --stream
Tests run: 874, Failures: 0, Errors: 0, Skipped: 2
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
[mvnf] Tests passed.

PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

@hmottestad hmottestad changed the title Gh 0000 lmdb readers full timeout GH-5807 Recover inactive LMDB readers when maxreaders is full May 1, 2026
@hmottestad hmottestad marked this pull request as draft May 1, 2026 13:42
@hmottestad hmottestad marked this pull request as ready for review May 1, 2026 15:16
@hmottestad hmottestad changed the title GH-5807 Recover inactive LMDB readers when maxreaders is full GH-5807 Recover LMDB readers safely when maxreaders is full May 1, 2026
@hmottestad hmottestad merged commit 5b59c48 into main May 2, 2026
12 checks passed
@hmottestad hmottestad deleted the GH-0000-lmdb-readers-full-timeout branch May 2, 2026 21:55
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.

LMDB read handles can remain exhausted after timed-out server queries

1 participant