zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eolive...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-1936: Server exits when unable to create data directory due to race
Date Thu, 23 Jan 2020 15:46:33 GMT
This is an automated email from the ASF dual-hosted git repository.

eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 689c8b2  ZOOKEEPER-1936: Server exits when unable to create data directory due to
race
689c8b2 is described below

commit 689c8b2c4ed264f1dd75db7cbde1f86fe4408f50
Author: Andor Molnar <andor@apache.org>
AuthorDate: Thu Jan 23 16:46:28 2020 +0100

    ZOOKEEPER-1936: Server exits when unable to create data directory due to race
    
    Resurrecting an ancient ticket which could be fixed with a simple patch.
    
    Jira mentions a scenario when auto purging tool is in use and Zookeeper server could have
a race condition when creating snapshot and data directories. (directory auto creating is
enabled by default)
    
    Double checking the directory existence might help with it.
    
    Author: Andor Molnar <andor@apache.org>
    
    Reviewers: Enrico Olivelli <eolivelli@apache.org>
    
    Closes #1225 from anmolnar/ZOOKEEPER-1936
---
 .../java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
index 661beb2..b6014ef 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
@@ -132,7 +132,7 @@ public class FileTxnSnapLog {
                     ZOOKEEPER_DATADIR_AUTOCREATE));
             }
 
-            if (!this.dataDir.mkdirs()) {
+            if (!this.dataDir.mkdirs() && !this.dataDir.exists()) {
                 throw new DatadirException("Unable to create data directory " + this.dataDir);
             }
         }
@@ -151,7 +151,7 @@ public class FileTxnSnapLog {
                     ZOOKEEPER_DATADIR_AUTOCREATE));
             }
 
-            if (!this.snapDir.mkdirs()) {
+            if (!this.snapDir.mkdirs() && !this.snapDir.exists()) {
                 throw new DatadirException("Unable to create snap directory " + this.snapDir);
             }
         }


Mime
View raw message