Github user phunt commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/436#discussion_r157918305
--- Diff: src/java/main/org/apache/zookeeper/server/persistence/Util.java
---
@@ -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;
--- End diff --
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
}
---