zookeeper-commits mailing list archives

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

andor pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


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

commit d461171d95e13184055c08f66fad4094ae5c5e36
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
    
    (cherry picked from commit 689c8b2c4ed264f1dd75db7cbde1f86fe4408f50)
    Signed-off-by: Andor Molnar <andor@apache.org>
---
 .../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 3939231..47f025d 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
@@ -123,7 +123,7 @@ public class FileTxnSnapLog {
                         + " is false). Please create this directory manually.");
             }
 
-            if (!this.dataDir.mkdirs()) {
+            if (!this.dataDir.mkdirs() && !this.dataDir.exists()) {
                 throw new DatadirException("Unable to create data directory "
                         + this.dataDir);
             }
@@ -143,7 +143,7 @@ public class FileTxnSnapLog {
                         + " is false). Please create this directory manually.");
             }
 
-            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