Skip to content

fix(dns): drop duplicate records when building a zone - #14113

Open
HarshMN2345 wants to merge 2 commits into
mainfrom
claude/dns-zone-duplicate-records
Open

HarshMN2345 wants to merge 2 commits into
mainfrom
claude/dns-zone-duplicate-records

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

A DNS RRset is a set, and RFC 2181 §5 makes publishing the same record twice invalid. When the rows a zone is built from contained duplicates, Zone published them twice.

Zone now keeps the first of any records identical in name, class, type, rdata, priority, weight and port. MX and SRV records that differ only in priority, weight or port are distinct records and both survive.

It applies when a zone is built, so zones whose rows are already duplicated are repaired without a data migration.

Test Plan

  • ZoneTest: identical records collapse for any type, keeping the first copy's TTL and leaving other names and types alone; MX and SRV records differing only outside rdata both remain.
  • Zone\FileTest: @ and the apex FQDN import as one record.

packages/dns unit suite, Pint and Rector pass locally. Three Lookup\RecursiveTest cases need the Swoole extension, which is not installed in my environment; they fail identically on main there.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

A DNS RRset is a set, and RFC 2181 section 5 makes publishing the same
record twice invalid. Zone keeps the first of any records identical in
name, class, type, rdata, priority, weight and port, so MX and SRV records
that differ only outside rdata both survive. Zones built from rows that
are already duplicated are repaired without a data migration.
@ghost

ghost commented Oct 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The deduplication preserves existing validation and record ordering, and no concrete defects were found in the changed code or its consumers.

Zone construction now removes duplicate records using name, class, type, rdata, priority, weight and port, retaining the first record and its TTL. Regression tests cover duplicate removal, preservation of distinct MX/SRV records, and duplicates imported with different apex-name spellings.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
packages/dns/src/Zone.php Deduplicates validated records before assigning the zone's record list.
packages/dns/tests/Zone/FileTest.php Tests duplicate apex CAA records imported from a zone file.
packages/dns/tests/ZoneTest.php Tests first-copy retention and preservation of distinct records.

Reviewed 4ff591e · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → claude/dns-zone-duplicate-records (after).

Metric Before After Change
🚀 Requests/sec 206.06 208.28 ⚪ +1.1%
⏱️ Latency P50 83.64 ms 82.88 ms ⚪ -0.9%
⏱️ Latency P95 198.06 ms 188.77 ms ⚪ -4.7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 82.88 188.77 13,110 208.28 -9.29
Account 153.72 304.41 690 11.43 -5.56
TablesDB 80.68 155.79 7,130 115.92 +10.68
Storage 75.57 163.66 3,450 57.64 -14.86
Functions 116.24 224.16 1,840 31.33 -23.57

Top API waits (after)

API request Max wait (ms)
account.prefs.update 475.14
account.name.update 407.02
functions.delete 382.5
tablesdb.rows.delete 357.09
functions.create 351.47

Drop the single-use helper and build the unique list in the loop that
already walks every record. Trim the tests to the cases the constructor
and the zone-file import each cover on their own, using example.com.
@HarshMN2345
HarshMN2345 force-pushed the claude/dns-zone-duplicate-records branch from acf7c97 to 4ff591e Compare October 5, 2026 08:04

This branch has not been deployed

No deployments
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.

1 participant