GIRAPH-1076 Race condition in FileTxnSnapLog

Summary:
org.apache.zookeeper.server.persistence.FileTxnSnapLog has a potential for race condition:

    if (!this.dataDir.exists()) {
        if (!this.dataDir.mkdirs()) {
               throw new IOException("Unable to create data directory " + this.dataDir);
        }
    }

If two threads try to create FileTxnSnapLog simultaneously it can trigger IOException.
We saw this happening in Giraph where FileTxnSnapLog is being created by PurgeTask created by DatadirCleanupManager and by InProcessZooKeeperRunner#runFromConfig.
Until and if ever, the zookeeper code is fixed, we need to make sure zookeeper starts first and only then starts PurgeTask.

Test Plan: run a few jobs and mvn clean verify

Reviewers: majakabiljo, dionysis.logothetis, heslami, maja.kabiljo

Reviewed By: maja.kabiljo

Differential Revision: https://reviews.facebook.net/D59883
1 file changed