zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phunt <...@git.apache.org>
Subject [GitHub] zookeeper pull request #436: ZOOKEEPER-2249: CRC check failed when preAllocS...
Date Wed, 20 Dec 2017 01:21:30 GMT
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
    }


---

Mime
View raw message