eolivelli commented on a change in pull request #1069: ZOOKEEPER-3056: Fails to
load database with missing snapshot file but with valid transaction log file.
URL: https://github.com/apache/zookeeper/pull/1069#discussion_r319645045
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/FileTxnSnapLog.java
##########
@@ -232,11 +242,19 @@ public long restore(DataTree dt, Map<Long, Integer>
sessions, PlayBackListener l
} else {
trustEmptyDB = autoCreateDB;
}
+
if (-1L == deserializeResult) {
/* this means that we couldn't find any snapshot, so we need to
* initialize an empty database (reported in ZOOKEEPER-2325) */
if (txnLog.getLastLoggedZxid() != -1) {
- throw new IOException("No snapshot found, but there are log
entries. " + "Something is broken!");
+ // ZOOKEEPER-3056: provides an escape hatch for users upgrading
+ // from old versions of zookeeper (3.4.x, pre 3.5.3).
+ if (!trustEmptySnapshot) {
+ throw new IOException(EMPTY_SNAPSHOT_WARNING + "Something
is broken!");
+ } else {
+ LOG.warn(EMPTY_SNAPSHOT_WARNING + "This should only be
allowed during upgrading.");
+ trustEmptySnapshot = false;
Review comment:
I am not an expert of this part, just want to share my doubts
Ideally we will hit the case of the issue only while the server is starting
up, not during internal reloads of the database, it is allowed to have such
lack of snapshot file only during bootstrap.
For instance I see that this method ("restore") is called in
QuorumPeer#getLastLoggedZxid()
if we refactor the code in the future and change the boot sequence this
change won't take effect.
I wonder if there is a cleaner way to allow this special case only during
"start" and not during all of the other code paths that leads to the
invocations of this method.
----------------------------------------------------------------
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