Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-4766: Avoid unnecessary snapshots during leader election #2153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rishabh-src
Copy link

No description provided.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. Thanks for your contribution!

One comment about code comment that we keep remember the motivation here.

@@ -546,7 +554,9 @@ public void loadData() throws IOException, InterruptedException {
.forEach(session -> killSession(session, zkDb.getDataTreeLastProcessedZxid()));

// Make a clean snapshot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the comment in what cases needSnapshot would be true/false and why.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added a comment 👍

@rishabh-src
Copy link
Author

Hi @tisonkun, thank you for taking a look! I have added an explanatory comment. Please let me know if this seems good to you. Also, @horizonzy mentioned a concern regarding the current session in the original PR #2085. Does anything need to be done to address this concern? I am not sure I fully understand that scenario.

@rishabh-src
Copy link
Author

Hi @tisonkun @horizonzy @eolivelli, thank you all for taking a look so far! Just wanted to check in to see if there are any other changes needed here or if the concern regarding the current session needs to be addressed in some way

Comment on lines +557 to +562
/* 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.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should answer your question, right @horizonzy ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snapFile = txnLogFactory.save(zkDb.getDataTree(), zkDb.getSessionWithTimeOuts(), syncSnap);

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the info @horizonzy , is this session info used for something upon restart that is necessary for correctness? Is it mainly important for telemetry? If it is not needed for correctness could skipping this snapshotting step during leader election be made a configurable option?

@rishabh-src
Copy link
Author

Hi @tisonkun @eolivelli @horizonzy, just wanted to check in to see if you have gotten a chance to take another look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants