Skip to content

Retry writes that fail with EOF - #1451

Open
HarveyBase wants to merge 1 commit into
segmentio:mainfrom
HarveyBase:fix/retry-eof-writes
Open

Retry writes that fail with EOF#1451
HarveyBase wants to merge 1 commit into
segmentio:mainfrom
HarveyBase:fix/retry-eof-writes

Conversation

@HarveyBase

Copy link
Copy Markdown

Description

The Writer currently treats io.ErrUnexpectedEOF and several connection errors as transient, but a plain io.EOF returned 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.EOF as a transient network error, allowing the existing Writer retry loop to handle it without changing retry limits or backoff behavior.

Testing

  • Added TestIsTransientNetworkErrorEOF to cover error classification.
  • Added TestWriterRetriesEOF using a fake RoundTripper: metadata succeeds, the first Produce returns io.EOF, and the second succeeds. The test asserts the write succeeds after exactly two Produce attempts.
  • gofmt and git diff --check pass.
  • go test -mod=mod . -run '^TestWriterRetriesEOF$' -count=1 -race -timeout=20s passes.
  • go test -mod=mod . -run 'Test(Error|IsTransientNetworkErrorEOF)$' -count=1 passes.
  • go vet ./... passes.
  • The integration tests requiring Kafka were not run because no local broker was available; the failures are environment connection-refused errors, not code failures.

Fixes #1352

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

EOF errors aren't retried by the Writer

1 participant