Avoid LMDB exception during recursive lookup #15090
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short description
It has been noticed that using
include
statements in Lua records served by LMDB would cause aSERVFAIL
result, with aDuplicate RW transaction
exception report in the server logs.This is caused by almost all LMDB transactions in the server being considered as RW transactions, even when they aren't; LMDB does not allow for more than one writer to operate at the same time, by design.This PR reworks the way the RO/RW status of the transaction is decided, and correctly uses RO transactions. Note that the existing lmdb access code here seems to be written assuming an LMDB RW transaction is not allowed to coexist with any other transaction, even RO ones. If I am wrong on this, I have a much simpler fix (one-liner) to propose instead.Edit: these changes introduced a chicken-and-egg problem, as they would not allow new databases to be created. Oops. So I am pushing the one-liner fix I mentioned instead, and crossing fingers.
Checklist
I have: