Source:
<code>public long restore(DataTree dt, Map<Long, Integer> sessions, PlayBackListener listener) throws IOException { long snapLoadingStartTime = Time.currentElapsedTime(); long deserializeResult = snapLog.deserialize(dt, sessions); ServerMetrics.getMetrics().STARTUP_SNAP_LOAD_TIME.add(Time.currentElapsedTime() - snapLoadingStartTime); FileTxnLog txnLog = new FileTxnLog(dataDir); boolean trustEmptyDB; File initFile = new File(dataDir.getParent(), "initialize"); if (Files.deleteIfExists(initFile.toPath())) { LOG.info("Initialize file found, an empty database will not block voting participation"); trustEmptyDB = true; } else { trustEmptyDB = autoCreateDB; } if (-1L == deserializeResult) { if (txnLog.getLastLoggedZxid() != -1) { if (!trustEmptySnapshot) { throw new IOException(EMPTY_SNAPSHOT_WARNING + "Something is broken!"); } else { LOG.warn(EMPTY_SNAPSHOT_WARNING + "This should only be allowed during upgrading."); <START> trustEmptySnapshot = false; <END> } } if (trustEmptyDB) { save(dt, (ConcurrentHashMap<Long, Integer>) sessions, false); return 0L; } else { LOG.warn("Unexpected empty data tree, setting zxid to -1"); dt.lastProcessedZxid = -1L; return -1L; } } long highestZxid = fastForwardFromEdits(dt, sessions, listener); DataTree.ZxidDigest snapshotZxidDigest = dt.getDigestFromLoadedSnapshot(); if (snapshotZxidDigest != null) { LOG.warn("Highest txn zxid 0x{} is not covering the snapshot " + "digest zxid 0x{}, which might lead to inconsistent state", Long.toHexString(highestZxid), Long.toHexString(snapshotZxidDigest.getZxid())); } return highestZxid; }</code><technical_language>I expert of this part, want share doubts Ideally hit case of issue while server is starting up, internal reloads of database, is allowed lack of snapshot file bootstrap. For instance I this method ("restore") is called in QuorumPeer#getLastLoggedZxid() if refactor code in future change boot sequence this change effect. I if is a cleaner allow this special case "start" of other code paths leads invocations of this method</technical_language>

Target:
public long restore(DataTree dt, Map<Long, Integer> sessions, PlayBackListener listener) throws IOException { long snapLoadingStartTime = Time.currentElapsedTime(); long deserializeResult = snapLog.deserialize(dt, sessions); ServerMetrics.getMetrics().STARTUP_SNAP_LOAD_TIME.add(Time.currentElapsedTime() - snapLoadingStartTime); FileTxnLog txnLog = new FileTxnLog(dataDir); boolean trustEmptyDB; File initFile = new File(dataDir.getParent(), "initialize"); if (Files.deleteIfExists(initFile.toPath())) { LOG.info("Initialize file found, an empty database will not block voting participation"); trustEmptyDB = true; } else { trustEmptyDB = autoCreateDB; } if (-1L == deserializeResult) { if (txnLog.getLastLoggedZxid() != -1) { if (!trustEmptySnapshot) { throw new IOException(EMPTY_SNAPSHOT_WARNING + "Something is broken!"); } else { LOG.warn(EMPTY_SNAPSHOT_WARNING + "This should only be allowed during upgrading."); } } if (trustEmptyDB) { save(dt, (ConcurrentHashMap<Long, Integer>) sessions, false); return 0L; } else { LOG.warn("Unexpected empty data tree, setting zxid to -1"); dt.lastProcessedZxid = -1L; return -1L; } } long highestZxid = fastForwardFromEdits(dt, sessions, listener); DataTree.ZxidDigest snapshotZxidDigest = dt.getDigestFromLoadedSnapshot(); if (snapshotZxidDigest != null) { LOG.warn("Highest txn zxid 0x{} is not covering the snapshot " + "digest zxid 0x{}, which might lead to inconsistent state", Long.toHexString(highestZxid), Long.toHexString(snapshotZxidDigest.getZxid())); } return highestZxid; }