horizonzy commented on code in PR #2153:
URL: https://github.com/apache/zookeeper/pull/2153#discussion_r1581839692
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java:
##########
@@ -545,8 +553,16 @@ public void loadData() throws IOException,
InterruptedException {
.filter(session ->
zkDb.getSessionWithTimeOuts().get(session) == null)
.forEach(session -> killSession(session,
zkDb.getDataTreeLastProcessedZxid()));
- // Make a clean snapshot
- takeSnapshot();
+ // Make a clean snapshot if needed
+ /* A snapshot is not needed when loading data during leader election.
A new snapshot is not needed to return to
+ * the current state because the current state was reached by loading
the data tree using an old snapshot.
+ * During leader election, there are no ongoing transactions that
could be lost either. If a snapshot is needed
+ * to send to a learner during leader election, that snapshot will be
taken as part of leader election, so
+ * snapshotting does not need to be done here as well.
+ */
Review Comment:
https://github.com/apache/zookeeper/blob/ee994fbca51f826e4b26d6a105866975d0007f6e/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java#L577
zookeeper's snapshot not only persists the dataTree but also persists the
session and session expiration time, I'm concerned that if we don't take a
snapshot here, the session data may not be accurate during the next restart.
@eolivelli /cc
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]