[
https://issues.apache.org/jira/browse/ZOOKEEPER-2488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16141473#comment-16141473
]
gaoshu edited comment on ZOOKEEPER-2488 at 8/30/17 10:32 AM:
-------------------------------------------------------------
Hi, [~hanm] I don't understand why need to protect the entire state of
QuorumPeer. I looked through the code. In my view, the QuorumPeer contains two
important state, QV and FLE. The FLE will be restarted when the QV changed
whatever the server state is, namely reconfig op. If the QuorumPeer is LEADER
or FOLLOWER, QuorumPeer state will be updated in function
QuorumPeer::processReconfig. But if QuorumPeer is LOOKING, shuttingDownLE may
be changed to true and QV updated, and then a new FLE object is created in main
loop of QuorumPeer. So I think the shuttingDownLE is only used by FLE to
inform QuorumPeer to create a new FLE object under the condition of
self.getServerState() == LOOKING. And it is sufficient to add volatile alone.
Please point our my errors, thank you very much.
was (Author: gaoshu):
Hi, [~hanm] I don't understand why need to protect the entire state of
QuorumPeer. I looked through the code. The QuorumPeer contains two important
state the QV and FLE. The FLE will be restarted when the QV changed whatever
the server state is, namely reconfig op. If the QuorumPeer is LEADER or
FOLLOWER, QuorumPeer state will be updated in function
QuorumPeer::processReconfig. But if QuorumPeer is LOOKING, shuttingDownLE may
be changed to true and QV updated, and then a new FLE object is created in main
loop of QuorumPeer. So I think the shuttingDownLE is only used by FLE to
inform QuorumPeer to create a new FLE object under the condition of
self.getServerState() == LOOKING. And it is sufficient to add volatile alone.
Please point our my errors, thank you very much.
> Unsynchronized access to shuttingDownLE in QuorumPeer
> -----------------------------------------------------
>
> Key: ZOOKEEPER-2488
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2488
> Project: ZooKeeper
> Issue Type: Bug
> Components: server
> Affects Versions: 3.5.2
> Reporter: Michael Han
> Assignee: gaoshu
> Fix For: 3.5.4, 3.6.0
>
>
> Access to shuttingDownLE in QuorumPeer is not synchronized here:
> https://github.com/apache/zookeeper/blob/3c37184e83a3e68b73544cebccf9388eea26f523/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java#L1066
> https://github.com/apache/zookeeper/blob/3c37184e83a3e68b73544cebccf9388eea26f523/src/java/main/org/
> The access should be synchronized as the same variable might be accessed
> in QuormPeer::restartLeaderElection, which is synchronized.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)