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

fix register type race #14897

Merged
merged 6 commits into from
Nov 29, 2024
Merged

Conversation

omoerbeek
Copy link
Member

@omoerbeek omoerbeek commented Nov 27, 2024

Short description

Actually seen in recursor, but auth could also have it in theory.

The issue is that you cannot call type register functions while the rest of the threads are doing their work. The actual fix is in reczones.cc, but also guard against this happening in other places (for both rec and auth), and while there remove the unused unregist function.

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)

@coveralls
Copy link

coveralls commented Nov 27, 2024

Pull Request Test Coverage Report for Build 12082288051

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 77 of 77 (100.0%) changed or added relevant lines in 6 files are covered.
  • 60 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-8.4%) to 64.699%

Files with Coverage Reduction New Missed Lines %
pdns/packethandler.cc 1 72.35%
pdns/misc.cc 1 63.88%
pdns/recursordist/sortlist.cc 2 74.12%
pdns/recursordist/test-syncres_cc2.cc 3 88.91%
pdns/iputils.hh 3 78.34%
pdns/rcpgenerator.cc 3 89.56%
pdns/recursordist/pdns_recursor.cc 4 72.57%
pdns/dnsdistdist/dnsdist-carbon.cc 6 63.51%
pdns/recursordist/syncres.cc 7 79.38%
pdns/recursordist/test-syncres_cc1.cc 8 89.58%
Totals Coverage Status
Change from base Build 12034691735: -8.4%
Covered Lines: 125874
Relevant Lines: 163645

💛 - Coveralls

Copy link
Member

@rgacogne rgacogne left a comment

Choose a reason for hiding this comment

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

I see that reportBasicTypes() is only used by unit tests, reportOtherTypes() is no longer used after this PR, so I think they could be removed in favor of always calling reportAllTypes(). Once this is done I don't think anyone should call ::report() directly (the remote backend unit tests currently do, but it looks like it could call reportAllTypes() instead), so perhaps it would make sense to disallow that (for example by making it take a required parameter to a const-reference to an opaque object, that can only be constructed by reportAllTypes()). This way we can call DNSRecordContent::lock() from reportAllTypes() directly, preventing a mistake later where we call reportAllTypes() without calling lock().
Does that make sense to you? If so I can look into it if you want me to.

pdns/dnsparser.hh Outdated Show resolved Hide resolved
@rgacogne
Copy link
Member

I pushed a commit implementing my proposal, please let me know if it looks good to you.

pdns/dnsrecords.cc Dismissed Show dismissed Hide dismissed
@omoerbeek
Copy link
Member Author

I'm mostly happy with this. One remark: we tend to move to /* unsued */ instead of a void cast of the unused parameter. If you agree I can change that before merge.

@rgacogne
Copy link
Member

rgacogne commented Nov 29, 2024

I'm mostly happy with this. One remark: we tend to move to /* unused */ instead of a void cast of the unused parameter. If you agree I can change that before merge.

Sure!

pdns/auth-main.cc Outdated Show resolved Hide resolved
pdns/recursordist/rec-main.cc Outdated Show resolved Hide resolved
{ \
unregist(1, QType::RNAME); \
unregist(254, QType::RNAME); \
(void)guard; \
Copy link
Member

Choose a reason for hiding this comment

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

You might want to change this one as well for consistency.

@omoerbeek omoerbeek merged commit 2d2dbb1 into PowerDNS:master Nov 29, 2024
78 checks passed
@omoerbeek omoerbeek deleted the rec-reload-zones-race branch November 29, 2024 10:12
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.

3 participants