fix(transfer): batch AXFR records by message size instead of count#8002
Merged
Conversation
The transfer plugin batched zone transfer records using a fixed count of 500 records per message. When a zone has many large records (e.g. long TXT or DNSSEC RRSIG), the resulting message can exceed the 64KB TCP limit, causing truncation or silent record loss. Replace the record count threshold with a byte size check using dns.Len per record, flushing before the batch exceeds 63000 bytes. Also fix a potential deadlock in the final batch send when the client disconnects mid-transfer by using a select on errCh. Fixes coredns#7859 Signed-off-by: umut-polat <52835619+umut-polat@users.noreply.github.com>
yongtang
approved these changes
Apr 4, 2026
Filippo125
pushed a commit
to Filippo125/coredns
that referenced
this pull request
Apr 10, 2026
…oredns#8002) Signed-off-by: Filippo <filippo.ferrazini@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The transfer plugin batches zone transfer records using a fixed count of 500 records per message. When a zone contains many large records (long TXT strings, DNSSEC RRSIG, etc.), the combined size can exceed the 64KB TCP message limit, causing truncation or silent record loss during AXFR.
Changes
plugin/transfer/transfer.go: replace thelen(rrs) > 500threshold with a byte-size check usingdns.Len()per record, flushing the batch before it exceeds 63000 bytes (leaving headroom for message header and question section)ch <- rrscould block forever sincetr.Outalready exited. Wrap it in aselectonerrChplugin/transfer/transfer_test.go: addTestTransferLargeRecordBatchingwith 300 TXT records (~250 bytes each, ~75KB total) asserting that every packed message stays withindns.MaxMsgSizeand no records are lostRepro (before fix)
Create 500 TXT records with 250-byte payloads, serve with the file plugin + transfer, then:
Fixes #7859