Repository navigation
fix(dns): keep one copy of identical records in a zone - #14371
Conversation
A zone holding the same record twice answered with both copies. RFC 2181 section 5 says servers should suppress records whose name, class, type and data are all equal, and some CAs read a doubled CAA answer as a conflict. Zone now keeps the first of each identical record, so every lookup and export works on a clean set.
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
This PR makes
Reviewed commit: 1fdbab0 |
🟢 Tier S · Ready to merge
Zone construction now keeps one copy of identical DNS records, retaining the lowest TTL while leaving records in their original first-occurrence order. Resolver lookups, wildcard synthesis, and zone-file export use the deduplicated records; regression tests cover constructor behavior and exact and wildcard answers. Latest changes: The newest commit moves and clarifies the deduplication comment beside its key and reformats the key fields across multiple lines without changing behavior.
📂 Walkthrough · 3
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
There was a problem hiding this comment.
Adds TTL-agnostic duplicate-record deduplication to the DNS Zone constructor, keyed on name/type/rdata.
Key findings
- 🟡 Dedup keeps first-seen TTL, not the lowest — Zone.php:53
RFC 2181 section 5.2 has every record of an RRset take the lowest TTL among them, so the copy kept now carries it, in the place of the first copy. An MX or SRV field left unset is encoded as 0, so it now matches an explicit 0.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The zone check keeps its original comment, the dedupe gets its own, and the key lists one field per line. No behaviour change.
…e-records fix(dns): keep one copy of identical records in a zone (cherry picked from commit b2be52c)
What does this PR do?
A
Zonebuilt with the same record twice answered every lookup with both copies. RFC 2181 §5 says servers should suppress records whose name, class, type and data are all equal. Some clients treat a doubled answer as an error: a certificate authority, for example, reads two identical CAA records as a conflict.Zonenow keeps one copy of each identical record. Records count as identical when they share name, type, class, rdata, priority, weight and port; an unset priority, weight or port counts as 0, the value it is encoded as. TTL is not compared: the copy kept has the lowest TTL among them, as RFC 2181 §5.2 has an RRset take, and it stays where the first copy was. Lookups, wildcard synthesis andFile::exporttherefore all work on a clean set.$recordsis no longer a promoted property, so the constructor can assign the deduplicated list.The rdata is compared as written.
File::importalready writes target names lowercase and without a trailing dot; records built directly with a target in another case or with a trailing dot are not matched.Test Plan
ZoneTest::testConstructorKeepsOneCopyOfIdenticalRecords:ResolverTest::testLookupAnswersIdenticalRecordsOnce: an exact CAA lookup and a wildcard CNAME synthesis each return one answer.mainand pass on this branch.Related PRs and Issues
Checklist