You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/11/10 11:38:28 UTC

[GitHub] [hadoop] haiyang1987 commented on a change in pull request #3630: HADOOP-17995. Stale record should be remove when DataNodePeerMetrics#dumpSendPacketDownstreamAvgInfoAsJson

haiyang1987 commented on a change in pull request #3630:
URL: https://github.com/apache/hadoop/pull/3630#discussion_r746505180



##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableRollingAverages.java
##########
@@ -167,7 +167,7 @@ synchronized void replaceScheduledTask(int windows, long interval,
   }
 
   @Override
-  public void snapshot(MetricsRecordBuilder builder, boolean all) {
+  public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {

Review comment:
       @ferhui @tomscut Thanks your comment.
   
   
   SpotBugs | module:hadoop-common-project/hadoop-common
   -- | --
     | Inconsistent synchronization of org.apache.hadoop.metrics2.lib.MutableRollingAverages.recordValidityMs; locked 66% of time Unsynchronized access at MutableRollingAverages.java:66% of time Unsynchronized access at MutableRollingAverages.java:[line 182]
   
   So consider add synchronized.
   Reference code MutableRatesWithAggregation#snapshot, the  method to add the synchronized
   
   > public class MutableRatesWithAggregation extends MutableMetric {
   > @Override
   >   public synchronized void snapshot(MetricsRecordBuilder rb, boolean all) {
   >     Iterator<WeakReference<ConcurrentMap<String, ThreadSafeSampleStat>>> iter =
   >         weakReferenceQueue.iterator();
   >     ...
   >   }
   > }
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org