[ https://issues.apache.org/jira/browse/ZOOKEEPER-1642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13577093#comment-13577093 ]
Flavio Junqueira commented on ZOOKEEPER-1642: --------------------------------------------- Thanks for the feedback, Thawan. I think I haven't made myself very clear. Let me try to add some more detail about this comment you've made: bq. I think the optimization of keeping the db across leader election (except when getting a SNAP or TRUNC) is worth doing, but that can be in a separate JIRA. QuorumPeer#getLastLoggedZxid is invoked in FLE#lookForLeader to set zxid of the initial vote. To get the zxid, we load the database in getLastLoggedZxid, and my understanding is that it must be loaded because it has been cleared with the shutdown when transitioning from LEADING/FOLLOWING to LOOKING. The change I'm proposing prevents a new leader from loading the database a second time when it starts executing Leader#lead(), more concretely when it calls loadData. Does it make more sense now? > 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