[
https://issues.apache.org/jira/browse/ZOOKEEPER-1642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13576109#comment-13576109
]
Flavio Junqueira commented on ZOOKEEPER-1642:
---------------------------------------------
Here is how I currently see it. The leader doesn't have to change its database
instance after being elected, but a follower might need to change it, though.
ZKDatabase is actually cleared in Learner#syncWithLeader(),
ZooKeeperServer#shutdown(), ZKDatabase#deserializeSnapshot(),
ZKDatabase#truncateLog(). In the case the follower requires changes, it will
end up clearing the database and reloading it with the corresponding changes.
About committedLog(), it is cleared in ZKDatabase#clear() and
ZKDatabase#addCommittedProposal(). addCommittedProposal is invoked in
ZKDatabase#loadDatabase() and FinalRequestProcessor#processRequest(). With the
patch I'm proposing, these methods would be invoked in the same way when a
follower needs to snap, take a diff, or truncate, so I don't expect a change of
behavior.
About a test, I'm happy to have it, but I'm still not very sure about what to
test. Should we test that a server contains all commits it should? If so, I'm
sure we have tests that do it already. Should we instead just check for the
content of the committedLog?
> Leader loading database twice
> -----------------------------
>
> Key: ZOOKEEPER-1642
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1642
> Project: ZooKeeper
> Issue Type: Bug
> Reporter: Flavio Junqueira
> Fix For: 3.5.0, 3.4.6
>
> Attachments: ZOOKEEPER-1642.patch
>
>
> The leader server currently loads the database before running leader election
> when trying to figure out the zxid it needs to use for the election and again
> when it starts leading. This is problematic for larger databases so we should
> remove the redundant load if possible.
> The code references are:
> # getLastLoggedZxid() in QuorumPeer;
> # loadData() in ZooKeeperServer.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira