ivankelly commented on a change in pull request #1233: ZOOKEEPER-3701 Split
brain on log disk full
URL: https://github.com/apache/zookeeper/pull/1233#discussion_r370042831
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
##########
@@ -499,23 +499,28 @@ public void save(
* @return true if able to truncate the log, false if not
* @throws IOException
*/
- public boolean truncateLog(long zxid) throws IOException {
- // close the existing txnLog and snapLog
- close();
-
- // truncate it
- FileTxnLog truncLog = new FileTxnLog(dataDir);
- boolean truncated = truncLog.truncate(zxid);
- truncLog.close();
-
- // re-open the txnLog and snapLog
- // I'd rather just close/reopen this object itself, however that
- // would have a big impact outside ZKDatabase as there are other
- // objects holding a reference to this object.
- txnLog = new FileTxnLog(dataDir);
- snapLog = new FileSnap(snapDir);
-
- return truncated;
+ public boolean truncateLog(long zxid) {
+ try {
+ // close the existing txnLog and snapLog
+ close();
+
+ // truncate it
+ FileTxnLog truncLog = new FileTxnLog(dataDir);
+ boolean truncated = truncLog.truncate(zxid);
+ truncLog.close();
+
+ // re-open the txnLog and snapLog
+ // I'd rather just close/reopen this object itself, however that
+ // would have a big impact outside ZKDatabase as there are other
+ // objects holding a reference to this object.
+ txnLog = new FileTxnLog(dataDir);
+ snapLog = new FileSnap(snapDir);
+
+ return truncated;
+ } catch (IOException e) {
Review comment:
I think it would be better to change the behaviour in QuorumPeer to
requestSystemExit any time it gets an unexpected exception. QuorumPeer runs in
a loop starting Learners and Leaders etc. There are objects shared between
iterations of these loops, and as far I can see little checking that the
objects are in a sane state if an exception occurred. Of course, I this is a
bigger change, so perhaps it can be done later.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services