-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(decoder): use configurable limit for max number of records in a record batch #3120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
created `getArrayLengthNoLimit` as record batches can contain more than `2*math.MaxUint16 records`. The packet decoder will make sure that the array length isn't greater than the number of bytes remaining to be decoding in the packet. Also added a test for large record counts. Fixes: IBM#3119 Signed-off-by: Ryan Belgrave <[email protected]>
Signed-off-by: Ryan Belgrave <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from me
@@ -254,3 +256,50 @@ func TestRecordBatchDecoding(t *testing.T) { | |||
} | |||
} | |||
} | |||
|
|||
func TestRecordBatchLargeNumRecords(t *testing.T) { | |||
numOfRecords := 10 + (2 * math.MaxUint16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how useful making this parameterizable is, when the CRC will change if the value changes, but then I like that it’s apparent and inarguable what length we’re encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I only set it as a var to make it obvious what it is. I kept forgetting what I had it set to during testing, so it's probably useful just to have it easily readable like you said haha.
@dnwe Yep makes sense to me, done. |
Signed-off-by: Ryan Belgrave <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks LGTM!
Hit the same issue in my setup. When will we get the new release with this fix ? |
…ecord batch (IBM#3120) Replace the `tmp > 2*math.MaxUint16` arbitrary number safety blanket with `tmp > MaxResponseSize` as we already have that constant (that a user can change via sarama.MaxResponseSize = ...) which is what we use for MaxBytes in a FetchRequest. Also added a test for large record counts. Fixes: IBM#3119
Replace the
tmp > 2*math.MaxUint16
arbitrary number safety blanket withtmp > MaxResponseSize
as we already have that constant (that a user can change via sarama.MaxResponseSize = ...) which is what we use for MaxBytes in a FetchRequest.Also added a test for large record counts.
Fixes: #3119