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

ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data #436

Closed
wants to merge 2 commits into from

Conversation

afine
Copy link
Contributor

@afine afine commented Dec 19, 2017

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

@afine afine changed the title [WIP] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data Dec 19, 2017
@@ -211,7 +211,7 @@ public static long padLogFile(FileOutputStream f,long currentSize,
long preAllocSize) throws IOException{
long position = f.getChannel().position();
if (position + 4096 >= currentSize) {
currentSize = currentSize + preAllocSize;
currentSize = position + preAllocSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch Abe! This looks like a reasonable fix, however it results in the doc'd invariant not being followed

"allocates space in the transaction log file in blocks of preAllocSize kilobytes"

I believe in this case you want something which will maintain the file as a multiple of this value.

Perhaps a while loop inside the conditional, replacing "currentSize = currentSize + preAllocSize;" with:

while (position + 4096 >= currentSize) {
currentSize = currentSize + preAllocSize
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@afine afine force-pushed the ZOOKEEPER-2249 branch 2 times, most recently from a97392b to e57676f Compare December 21, 2017 22:23
@asfgit asfgit closed this in 4d629d2 Jan 18, 2018
asfgit pushed a commit that referenced this pull request Jan 18, 2018
…data

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes #436 from afine/ZOOKEEPER-2249 and squashes the following commits:

f3bc06c [Abraham Fine] Improve testing and respond to phunt's comment
44ad057 [Abraham Fine] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data

Change-Id: Id8ba9ad730760cb78672127b8c0e02db60b4e87d
(cherry picked from commit 4d629d2)
Signed-off-by: Patrick Hunt <phunt@apache.org>
asfgit pushed a commit that referenced this pull request Jan 18, 2018
…data

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes #436 from afine/ZOOKEEPER-2249 and squashes the following commits:

f3bc06c [Abraham Fine] Improve testing and respond to phunt's comment
44ad057 [Abraham Fine] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data

Change-Id: Id8ba9ad730760cb78672127b8c0e02db60b4e87d
(cherry picked from commit 4d629d2)
Signed-off-by: Patrick Hunt <phunt@apache.org>
@phunt
Copy link
Contributor

phunt commented Jan 18, 2018

LGTM +1. Thanks @afine . Committed to 3.4/3.5/trunk.

maoling pushed a commit to maoling/zookeeper that referenced this pull request Jan 26, 2018
…data

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes apache#436 from afine/ZOOKEEPER-2249 and squashes the following commits:

f3bc06c [Abraham Fine] Improve testing and respond to phunt's comment
44ad057 [Abraham Fine] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data

Change-Id: Id8ba9ad730760cb78672127b8c0e02db60b4e87d
lvfangmin pushed a commit to lvfangmin/zookeeper that referenced this pull request Jun 17, 2018
…data

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes apache#436 from afine/ZOOKEEPER-2249 and squashes the following commits:

f3bc06c [Abraham Fine] Improve testing and respond to phunt's comment
44ad057 [Abraham Fine] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data

Change-Id: Id8ba9ad730760cb78672127b8c0e02db60b4e87d
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Sep 3, 2022
…data

This bug is caused by an issue in our file padding logic. We calculate an incorrect position to add padding when appending to the transaction log, this often corrupts a transaction. When the log is read the CRC check will correctly fail.

Author: Abraham Fine <afine@apache.org>

Reviewers: phunt@apache.org

Closes apache#436 from afine/ZOOKEEPER-2249 and squashes the following commits:

f3bc06c [Abraham Fine] Improve testing and respond to phunt's comment
44ad057 [Abraham Fine] ZOOKEEPER-2249: CRC check failed when preAllocSize smaller than node data

Change-Id: Id8ba9ad730760cb78672127b8c0e02db60b4e87d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants