[ https://issues.apache.org/jira/browse/ZOOKEEPER-2967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16356773#comment-16356773 ]
ASF GitHub Bot commented on ZOOKEEPER-2967: ------------------------------------------- GitHub user mfenes opened a pull request: https://github.com/apache/zookeeper/pull/459 ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup This PR adds a check to protect ZK against configuring dataDir and dataLogDir opposingly. When FileTxnSnapLog is created, it checks if transaction log directory contains snapshot files or vice versa, snapshot directory contains transaction log files. If so, the check throws LogdirContentCheckException or SnapdirContentCheckException, respectively, which translates to DatadirException at ZK startup in QuorumPeerMain and ZooKeeperServerMain. If the two directories are the same, then no check is done. For testing, I've added 4 new unit tests which cover the following cases: transaction log and snapshot directories are different and they are used correctly (no Exception) transaction log and snapshot directories are the same (in this case no check is done) transaction log and snapshot directories are different and transaction log directory contains snapshot files (LogdirContentCheckException -> ZK quits) transaction log and snapshot directories are different and snapshot directory contains transaction log files (SnapdirContentCheckException -> ZK quits) You can merge this pull request into a Git repository by running: $ git pull https://github.com/mfenes/zookeeper ZOOKEEPER-2967_3.4 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/zookeeper/pull/459.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #459 ---- commit 3cebb86cf5b2ab7561ee1a25e6eb7cc10bb7a5b6 Author: Mark Fenes <mfenes@...> Date: 2018-01-19T23:16:07Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup commit a0ef2ce168e65919a2613e8e7dcb0effaf3f838a Author: Mark Fenes <mfenes@...> Date: 2018-01-20T00:57:13Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup Replaced |= as this operator is not short-circuit commit 3d978556fc525c9f93db5c73a59d2cf52f847d6c Author: Mark Fenes <mfenes@...> Date: 2018-01-29T23:08:11Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup FilenameFilter, includes dot in log/snapshot filename check, improved/shortened unit test code, added @Before and @After to set up and delete temporary test directories. commit 4096a2500961e3015a8ec009ecfa088b6642a1e8 Author: Mark Fenes <mfenes@...> Date: 2018-02-01T23:21:45Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup Replaced "log" and "snapshot" strings with constants FileTxnLog.LOG_FILE_PREFIX and FileSnap.SNAPSHOT_FILE_PREFIX. Used Util.makeLogName when creating new transaction log file to make sure creation and verification follows the same file name pattern. Added reference to ZOOKEEPER-2967 to explain why this check is needed. Cleanup/refactoring of unit test FileTxnSnapLogTest. commit 5d8b5d0462700c70d317bc3de3989a03081cba36 Author: Mark Fenes <mfenes@...> Date: 2018-02-07T12:53:35Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup Fixed possible NP issues. commit 666a1b0a1bd33406f26c29df1407f75c94675d0f Author: Mark Fenes <mfenes@...> Date: 2018-02-08T10:31:46Z ZOOKEEPER-2967: Add check to validate dataDir and dataLogDir parameters at startup Required changes to backport ZOOKEEPER-2967 from master to 3.4. ---- > Add check to validate dataDir and dataLogDir parameters at startup > ------------------------------------------------------------------ > > Key: ZOOKEEPER-2967 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2967 > Project: ZooKeeper > Issue Type: Improvement > Components: server > Affects Versions: 3.4.11 > Reporter: Andor Molnar > Assignee: Mark Fenes > Priority: Major > Labels: startup, validation > Fix For: 3.5.4, 3.6.0, 3.4.12 > > > According to -ZOOKEEPER-2960- we should at a startup check to validate that > dataDir and dataLogDir parameters are set correctly. > Perhaps we should introduce a check of some kind? If datalogdir is different > that datadir and snapshots exist in datalogdir we throw an exception and quit. -- This message was sent by Atlassian JIRA (v7.6.3#76005)