Skip to content

Commit

Permalink
Check for insufficient data when we try to get the records.
Browse files Browse the repository at this point in the history
In some corner cases (like v2 records produced on the topic but the
sarama consumer uses v0 Fetch API with a limit less than one record size)
we might receive a truncated record batch. We want to be able to make
progress by increasing the fetch limit, so don't return an error, but
rater mark the batch as partial trailing record.
  • Loading branch information
vlad-arista committed Dec 5, 2017
1 parent 66fbffd commit eee4c71
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions record_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ func (b *RecordBatch) decode(pd packetDecoder) (err error) {
bufSize := int(batchLen) - recordBatchOverhead
recBuffer, err := pd.getRawBytes(bufSize)
if err != nil {
if err == ErrInsufficientData {
b.PartialTrailingRecord = true
b.Records = nil
return nil
}
return err
}

Expand Down

0 comments on commit eee4c71

Please sign in to comment.