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 growing destination buffer during WAL entry encoding #5079

Merged
merged 3 commits into from
Dec 10, 2015
Merged

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Dec 10, 2015

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

@@ -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) {
Copy link
Contributor

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?

Copy link
Contributor

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.

jwilder and others added 2 commits December 10, 2015 11:46
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
@otoolep
Copy link
Contributor

otoolep commented Dec 10, 2015

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.

@otoolep
Copy link
Contributor

otoolep commented Dec 10, 2015

I had to rebase and force-push due to CHANGELOG conflicts.

otoolep added a commit that referenced this pull request Dec 10, 2015
Fix growing destination buffer during WAL entry encoding
@otoolep otoolep merged commit 2f67542 into master Dec 10, 2015
@otoolep otoolep deleted the jw-5075 branch December 10, 2015 19:56
@otoolep
Copy link
Contributor

otoolep commented Dec 10, 2015

Cherry-picked to 0.9.6

@otoolep otoolep mentioned this pull request Dec 15, 2015
@jwilder jwilder added this to the 0.10.0 milestone Feb 1, 2016
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