Skip to content

Commit

Permalink
Don't close connection when end of batch is read correctly (segmentio…
Browse files Browse the repository at this point in the history
…#409)

io.EOF is used as a marker that a batch of messages has been
completely read.  The batch will repackage an io.EOF from the
underlying connection as an io.ErrUnexpectedEOF.

The previous behavior closed the connection on an io.EOF and
restarted the reader loop, which will be much less efficient than
continuing to use the connnection.
  • Loading branch information
Steve van Loben Sels authored Mar 11, 2020
1 parent e7c1f56 commit efce7b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ func (r *reader) run(ctx context.Context, offset int64) {
// block relies on the batch repackaging real io.EOF errors as
// io.UnexpectedEOF. otherwise, we would end up swallowing real
// errors here.
break readLoop
errcount = 0
case UnknownTopicOrPartition:
r.withErrorLogger(func(log Logger) {
log.Printf("failed to read from current broker for partition %d of %s at offset %d, topic or parition not found on this broker, %v", r.partition, r.topic, offset, r.brokers)
Expand Down

0 comments on commit efce7b6

Please sign in to comment.