[
https://issues.apache.org/jira/browse/ZOOKEEPER-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hongchao Deng updated ZOOKEEPER-1972:
-------------------------------------
Description:
The findbugs complains about incrementing a volatile variable in
[AuthFastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java#L737]
and
[FastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java]:
{code}
volatile long logicalclock; /* Election instance */
...
logicalclock++;
{code}
Actually this is a bug. It should use AtomicLong here instead of volatile.
Leader.java and
[QuorumPeer.java|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java#L428]
and LearnerHandler.java:
{code}
volatile int tick;
{code}
I don't think it needs volatile here. The tick
was:
The findbugs complains about incrementing a volatile variable in
[AuthFastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java#L737]
and
[FastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java]:
{code}
volatile long logicalclock; /* Election instance */
...
logicalclock++;
{code}
Also Leader.java and
[QuorumPeer.java|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java#L428]
and LearnerHandler.java:
{code}
volatile int tick;
...
tick++;
{code}
Actually this is a bug. It should use AtomicLong/AtomicInteger here instead of
volatile.
> Use AtomicLong for logical clock
> --------------------------------
>
> Key: ZOOKEEPER-1972
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1972
> Project: ZooKeeper
> Issue Type: Sub-task
> Reporter: Hongchao Deng
> Assignee: Hongchao Deng
> Fix For: 3.5.0
>
> Attachments: ZOOKEEPER-1972.patch
>
>
> The findbugs complains about incrementing a volatile variable in
> [AuthFastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java#L737]
> and
> [FastLeaderElection|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java]:
> {code}
> volatile long logicalclock; /* Election instance */
> ...
> logicalclock++;
> {code}
> Actually this is a bug. It should use AtomicLong here instead of volatile.
> Leader.java and
> [QuorumPeer.java|https://github.com/apache/zookeeper/blob/087abf83684167ae56864fe4c3be0079fa653266/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java#L428]
> and LearnerHandler.java:
> {code}
> volatile int tick;
> {code}
> I don't think it needs volatile here. The tick
--
This message was sent by Atlassian JIRA
(v6.2#6252)