[
https://issues.apache.org/jira/browse/HDFS-4106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13482772#comment-13482772
]
Jing Zhao commented on HDFS-4106:
---------------------------------
Thanks for the comments Brandon! So the cost of a volatile read/write may be an
extra memory access. For a BPServiceActor thread which communicate with NN
periodically, I think this may not cause a performance problem (also
considering variables like lastHeartbeat are not accessed a lot). While without
the volatile keyword it is possible that the triggerHeartbeatForTests cannot
trigger the heartbeat as it intends to, since the change of lastheartbeat may
not be seen by the actor thread. Also the testing thread may be waiting for an
unknown period of time because the change of lastheartbeat by the actor thread
may not be seen by the testing thread.
> BPServiceActor#lastHeartbeat, lastBlockReport and lastDeletedReport should be
> declared as volatile
> --------------------------------------------------------------------------------------------------
>
> Key: HDFS-4106
> URL: https://issues.apache.org/jira/browse/HDFS-4106
> Project: Hadoop HDFS
> Issue Type: Bug
> Affects Versions: 3.0.0
> Reporter: Jing Zhao
> Assignee: Jing Zhao
> Priority: Minor
> Attachments: HDFS-4106-trunk.001.patch
>
>
> All these variables may be assigned/read by a testing thread (through
> BPServiceActor#triggerXXX) while also assigned/read by the actor thread. Thus
> they should be declared as volatile to make sure the "happens-before"
> consistency.
--
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