Skip to content

Enable safeRestore config and retry op on recovery#548

Merged
satyakigh merged 1 commit intomainfrom
lmdb-retry
Apr 28, 2026
Merged

Enable safeRestore config and retry op on recovery#548
satyakigh merged 1 commit intomainfrom
lmdb-retry

Conversation

@satyakigh
Copy link
Copy Markdown
Collaborator

@satyakigh satyakigh requested a review from a team as a code owner April 27, 2026 23:48
if (this.closed) return;

try {
const staleLocks = this.env.readerCheck();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this work?

Copy link
Copy Markdown
Collaborator Author

@satyakigh satyakigh Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readerCheck clears out stale reader transaction entries from the reader lock table.

LMDB uses a shared lock table to track active read transactions across processes/threads. If a process crashes or exits without properly closing its read transaction, its entry remains in the table as a stale reader. Stale readers are problematic because LMDB can't reclaim database pages that were in use at the time of that reader's snapshot - this causes the database file to grow continuously since old pages can never be freed.

db.readerCheck() scans the reader lock table, detects entries belonging to processes/PIDs that no longer exist, and clears them. It returns the number of stale entries that were removed.

@satyakigh satyakigh merged commit f285289 into main Apr 28, 2026
15 checks passed
@satyakigh satyakigh deleted the lmdb-retry branch April 28, 2026 14:45
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