fix(decoder): use configurable limit for max number of records in a record batch#3120
Merged
fix(decoder): use configurable limit for max number of records in a record batch#3120
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 <rbelgrave@confluent.io>
puellanivis
reviewed
Mar 6, 2025
Signed-off-by: Ryan Belgrave <ryan@belgrave.me>
puellanivis
reviewed
Mar 6, 2025
| } | ||
|
|
||
| func TestRecordBatchLargeNumRecords(t *testing.T) { | ||
| numOfRecords := 10 + (2 * math.MaxUint16) |
Collaborator
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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.
gunli
reviewed
Mar 10, 2025
Collaborator
Contributor
Author
|
@dnwe Yep makes sense to me, done. |
Signed-off-by: Ryan Belgrave <ryan@belgrave.me>
|
Hit the same issue in my setup. When will we get the new release with this fix ? |
Uduchi2nd
pushed a commit
to mixpanel/sarama
that referenced
this pull request
May 29, 2025
…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
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.
Replace the
tmp > 2*math.MaxUint16arbitrary number safety blanket withtmp > MaxResponseSizeas 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