Retry writes that fail with EOF - #1451
Open
HarveyBase wants to merge 1 commit into
Open
Conversation
Treat io.EOF as a transient network error so Writer retries writes interrupted by broker connection closures. Add focused error classification and Writer regression tests using a fake transport. Fixes segmentio#1352
HarveyBase
force-pushed
the
fix/retry-eof-writes
branch
from
September 4, 2026 07:11
c891b8f to
ce77011
Compare
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.
Description
The Writer currently treats
io.ErrUnexpectedEOFand several connection errors as transient, but a plainio.EOFreturned while a broker connection is being closed is not retried. During routine broker rolling maintenance, this can turn a recoverable connection interruption into a permanent write failure.This change classifies
io.EOFas a transient network error, allowing the existing Writer retry loop to handle it without changing retry limits or backoff behavior.Testing
TestIsTransientNetworkErrorEOFto cover error classification.TestWriterRetriesEOFusing a fakeRoundTripper: metadata succeeds, the first Produce returnsio.EOF, and the second succeeds. The test asserts the write succeeds after exactly two Produce attempts.gofmtandgit diff --checkpass.go test -mod=mod . -run '^TestWriterRetriesEOF$' -count=1 -race -timeout=20spasses.go test -mod=mod . -run 'Test(Error|IsTransientNetworkErrorEOF)$' -count=1passes.go vet ./...passes.Fixes #1352