-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 growing destination buffer during WAL entry encoding #5079
Conversation
@@ -366,6 +366,13 @@ func (w *WriteWALEntry) Encode(dst []byte) ([]byte, error) { | |||
|
|||
for k, v := range w.Values { | |||
|
|||
// Make sure we have enough space in our buf before copying. If not, | |||
// grow the buf. | |||
if len(dst[:n])+2+len(k)+len(v)*8+4 > len(dst) { |
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.
So this change is because the buffer was insufficiently big for even the first batch, right?
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 would love to see these magic numbers const out.
The test to see if the destination buffer for encoding and decoding a WAL entry was broken and would cause a panic if there were large batches that would overflow the buffer size. Fixes #5075
OK, I checked out the branch, and generally follow it now. I'd like to understand @jwilder why you moved the earlier block, but I'm merging now. |
I had to rebase and force-push due to CHANGELOG conflicts. |
Fix growing destination buffer during WAL entry encoding
Cherry-picked to 0.9.6 |
The test to see if the destination buffer for encoding and decoding a WAL
entry was broken and would cause a panic if there were large batches that
would overflow the buffer size.
Fixes #5075