[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15045593#comment-15045593
 ] 

Chris Nauroth commented on ZOOKEEPER-2332:
------------------------------------------

bq. The zookeeper server was killed after creating a new txn log file before 
flushing the log header to the log.

This sounds like a case where we should rely on an atomicity guarantee from the 
file system to make sure that the new log file is committed in a consistent 
state.  For example:

# Create new log file named log.<zxid>.new.
# Write and flush header.
# Atomically rename log.<zxid>.new to log.<zxid>.

This would ensure that any file named log.\* that is not named log.\*.new is a 
valid transaction log file containing at least a complete header.  After that, 
the pre-existing log file padding and checksumming logic should be sufficient 
to protect against things like a partially serialized transaction.  At read 
time, the code can self-recover from prior errors by ignoring and deleting 
leftover "uncommitted" log.\*.new files.

I think this would be less brittle than trying to detect a bad log file at load 
time.

> Zookeeper failed to start for empty txn log
> -------------------------------------------
>
>                 Key: ZOOKEEPER-2332
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2332
>             Project: ZooKeeper
>          Issue Type: Bug
>    Affects Versions: 3.4.6
>            Reporter: Liu Shaohui
>            Priority: Critical
>             Fix For: 3.6.0
>
>         Attachments: ZOOKEEPER-2332-v001.diff
>
>
> We found that the zookeeper server with version 3.4.6 failed to start for 
> there is a empty txn log in log dir.  
> I think we should skip the empty log file during restoring the datatree. 
> Any suggestion?
> {code}
> 2015-11-27 19:16:16,887 [myid:] - ERROR [main:ZooKeeperServerMain@63] - 
> Unexpected exception, exiting abnormally
> java.io.EOFException
> at java.io.DataInputStream.readInt(DataInputStream.java:392)
> at org.apache.jute.BinaryInputArchive.readInt(BinaryInputArchive.java:63)
> at 
> org.apache.zookeeper.server.persistence.FileHeader.deserialize(FileHeader.java:64)
> at 
> org.apache.zookeeper.server.persistence.FileTxnLog$FileTxnIterator.inStreamCreated(FileTxnLog.java:576)
> at 
> org.apache.zookeeper.server.persistence.FileTxnLog$FileTxnIterator.createInputArchive(FileTxnLog.java:595)
> at 
> org.apache.zookeeper.server.persistence.FileTxnLog$FileTxnIterator.goToNextLog(FileTxnLog.java:561)
> at 
> org.apache.zookeeper.server.persistence.FileTxnLog$FileTxnIterator.next(FileTxnLog.java:643)
> at 
> org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:158)
> at org.apache.zookeeper.server.ZKDatabase.loadDataBase(ZKDatabase.java:223)
> at 
> org.apache.zookeeper.server.ZooKeeperServer.loadData(ZooKeeperServer.java:272)
> at 
> org.apache.zookeeper.server.ZooKeeperServer.startdata(ZooKeeperServer.java:399)
> at 
> org.apache.zookeeper.server.NIOServerCnxnFactory.startup(NIOServerCnxnFactory.java:122)
> at 
> org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:113)
> at 
> org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:86)
> at 
> org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
> at 
> org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
> at 
> org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to