Skip to content
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

Merged
merged 3 commits into from
Mar 20, 2020

Conversation

hossain-rayhan
Copy link
Contributor

*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 of data 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.

@@ -196,8 +196,9 @@ func (outputPlugin *OutputPlugin) AddRecord(record map[interface{}]interface{},
}

newDataSize := len(data)
Copy link
Contributor

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"

Copy link
Contributor

@PettitWesley PettitWesley Mar 20, 2020

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..

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Contributor

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...

Copy link
Contributor Author

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.

@hossain-rayhan hossain-rayhan merged commit e1f88d7 into aws:master Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants