-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix: Update logic to calculate the maximum record size #22
Conversation
kinesis/kinesis.go
Outdated
@@ -196,8 +196,9 @@ func (outputPlugin *OutputPlugin) AddRecord(record map[interface{}]interface{}, | |||
} | |||
|
|||
newDataSize := len(data) |
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.
Add the len(partitionKey)
here so that this var is the actual "new data size"
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.
Also, you should error and discard the record if newDataSize > 1 MiB
. That's the max size for a record. As far as I can tell we do not currently check for that in this plugin..
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.
Add the
len(partitionKey)
here so that this var is the actual "new data size"
I intentionally kept them separated so that the next developer can easily understand how the actual dataLength is calculated.
dataLength = newDataSize + partitionKeySize
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.
Ok
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.
I think you could call it newRecordSize
though and they could see that the value is len(data) + len(partitionKey)
which would accomplish the same thing with less code...
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.
Also, you should error and discard the record if
newDataSize > 1 MiB
. That's the max size for a record. As far as I can tell we do not currently check for that in this plugin..
Good point. +1
I added another commit.
*Issue #21
Description of changes:
Maximum record size for kinesis stream
PutRecords
is 5mb including the size of partition keys. Earlier, we only considered the size ofdata
part of each record. This fix will stop the unexpected limit exceeds exception.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.