Github user maoling commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/356#discussion_r137008765
  
    --- Diff: 
src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java ---
    @@ -399,18 +403,20 @@ public boolean truncate(long zxid) throws IOException 
{
                 }
                 long pos = input.getPosition();
                 // now, truncate at the current position
    -            RandomAccessFile raf=new RandomAccessFile(itr.logFile,"rw");
    +            raf = new RandomAccessFile(itr.logFile, "rw");
                 raf.setLength(pos);
    -            raf.close();
                 while(itr.goToNextLog()) {
    -                if (!itr.logFile.delete()) {
    -                    LOG.warn("Unable to truncate {}", itr.logFile);
    +                try {
    +                    Files.delete(itr.logFile.toPath());
    +                } catch (NoSuchFileException e) {
                     }
                 }
    --- End diff --
    
    - A option:  remain the origin code in the master branch unchanged.just log 
the `itr.logFile` and `zxid`
    - B option:  choose `Files.delete`  because it throws `exception` rather 
than `itr.logFile.delete()` returns `boolean` ,**dont't catch it** and it will 
be caught in `Learner.java#syncWithLeader` and log it with `zxid`
    - am I right?


---

Reply via email to