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

lmdb-safe: add prefix() cursor; use it in list/lookup/get #15176

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

Habbie
Copy link
Member

@Habbie Habbie commented Feb 19, 2025

Short description

Posted for first review. Bit draft still.

After updating lookup() and get() for the prefix method, I also had to update list() (as that also just prepares us for get()).

I don't think any other functions in lmdbbackend.cc need updating to work correctly; I do think a few more could benefit.

I copied the StringView define from lmdbbackend.cc but I'm not sure it's doing the right thing (in either place perhaps). It's also possible that we can fully rely on having the right Boost version these days.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • 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)
  • checked that this code was merged to master

@coveralls
Copy link

coveralls commented Feb 19, 2025

Pull Request Test Coverage Report for Build 13587579875

Details

  • 23 of 23 (100.0%) changed or added relevant lines in 2 files are covered.
  • 11639 unchanged lines in 206 files lost coverage.
  • Overall coverage increased (+3.5%) to 64.486%

Files with Coverage Reduction New Missed Lines %
ext/lmdb-safe/lmdb-typed.cc 1 89.66%
pdns/auth-catalogzone.hh 1 66.67%
pdns/dnsdistdist/dnsdist-kvs.hh 1 55.0%
pdns/dnsdistdist/dnsdist-lua-hooks.cc 1 94.59%
pdns/dnsdistdist/dnsdist-session-cache.cc 1 62.86%
pdns/dnswriter.hh 1 76.6%
pdns/dynlistener.hh 1 0.0%
pdns/inflighter.cc 1 90.48%
pdns/qtype.hh 1 86.96%
pdns/recursordist/nod.hh 1 92.59%
Totals Coverage Status
Change from base Build 13576694012: 3.5%
Covered Lines: 127630
Relevant Lines: 166927

💛 - Coveralls

Copy link
Contributor

@miodvallat miodvallat left a comment

Choose a reason for hiding this comment

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

The logic of the for loop in LMDBBackend::updateDNSSECOrderNameAndAuth might also be able to benefit from this, the for condition being now implied by the fact we didn't break out of it.

@Habbie
Copy link
Member Author

Habbie commented Feb 20, 2025

The logic of the for loop in LMDBBackend::updateDNSSECOrderNameAndAuth might also be able to benefit from this, the for condition being now implied by the fact we didn't break out of it.

Indeed!

Unrelated thought: perhaps other cursor initializers should reset (empty) d_prefix - I don't know if we have callers that reuse cursors for different lookup purposes.

@@ -1534,7 +1534,7 @@ void LMDBBackend::lookup(const QType& type, const DNSName& qdomain, int zoneId,
d_matchkey = co(zoneId, relqname, type.getCode());
Copy link
Member Author

Choose a reason for hiding this comment

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

this case (including type) does not even need to be a prefix query - a simple get by this key would yield the same result. But, after this PR, I'm not sure it matters much.

@miodvallat
Copy link
Contributor

Resetting d_prefix sounds like something we want to do, indeed.

@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

Resetting d_prefix sounds like something we want to do, indeed.

Because I'm curious I'm going to assert emptiness first, see what dies :)

@miodvallat
Copy link
Contributor

Because I'm curious I'm going to assert emptiness first, see what dies :)

Girl smiling in front of house in fire meme, with text "risk accepted" added

@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

Because I'm curious I'm going to assert emptiness first, see what dies :)

nothing died, but it made me realise that lower_bound needs to be refactored so it can empty the prefix without breaking prefix(), which relies on lower_bound :)

@Habbie Habbie force-pushed the lmdb-prefix-lookup branch from 33f55e5 to 45c1bc4 Compare February 28, 2025 09:30
@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

The logic of the for loop in LMDBBackend::updateDNSSECOrderNameAndAuth might also be able to benefit from this, the for condition being now implied by the fact we didn't break out of it.

done

@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

ready for another review round (I'll squash later)

Copy link
Contributor

@miodvallat miodvallat left a comment

Choose a reason for hiding this comment

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

Looking good.

@Habbie Habbie force-pushed the lmdb-prefix-lookup branch from a95908c to bdf6ccd Compare February 28, 2025 11:03
@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

squashed, plus two new commits. Waiting for green :)

@Habbie Habbie marked this pull request as ready for review February 28, 2025 11:03
@miodvallat
Copy link
Contributor

Good catch with the 3rd commit.

@Habbie
Copy link
Member Author

Habbie commented Feb 28, 2025

Good catch with the 3rd commit.

I was renaming the short vars because clang-tidy complained and then it hit me. I'm sure the bruises won't stick around for too long.

@miodvallat
Copy link
Contributor

Ah, yes, good old "commit by serendipity" technique.

@Habbie Habbie force-pushed the lmdb-prefix-lookup branch from bdf6ccd to e8c23ea Compare February 28, 2025 11:53
@Habbie Habbie merged commit 3223190 into PowerDNS:master Feb 28, 2025
87 checks passed
@Habbie Habbie deleted the lmdb-prefix-lookup branch February 28, 2025 12:34
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.

3 participants