Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid LMDB exception during recursive lookup #15090

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

miodvallat
Copy link
Contributor

@miodvallat miodvallat commented Jan 27, 2025

Short description

It has been noticed that using include statements in Lua records served by LMDB would cause a SERVFAIL result, with a Duplicate 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:

  • read the CONTRIBUTING.md document (although not recently)
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • ticked an even number of boxes

@coveralls
Copy link

coveralls commented Jan 27, 2025

Pull Request Test Coverage Report for Build 12992083679

Details

  • 1 of 2 (50.0%) changed or added relevant lines in 1 file are covered.
  • 126 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.05%) to 64.691%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ext/lmdb-safe/lmdb-safe.cc 1 2 50.0%
Files with Coverage Reduction New Missed Lines %
pdns/validate.cc 1 68.33%
pdns/pollmplexer.cc 1 83.66%
pdns/recursordist/sortlist.cc 2 72.94%
pdns/recursordist/aggressive_nsec.cc 2 66.32%
pdns/tcpiohandler.cc 2 68.18%
pdns/misc.hh 3 87.62%
pdns/packethandler.cc 3 72.4%
pdns/signingpipe.cc 3 86.33%
pdns/iputils.cc 3 56.84%
pdns/recursordist/rec-main.cc 3 62.41%
Totals Coverage Status
Change from base Build 12986070468: -0.05%
Covered Lines: 127807
Relevant Lines: 166473

💛 - Coveralls

The check was too strict and would prevent any RO transaction to coexist
with RW transactions. But LMDB is designed to allow this - on the other
hand there can be only one active RW transaction at a time.
@miodvallat miodvallat added this to the auth-5 milestone Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants