-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-17995. Stale record should be remove when DataNodePeerMetrics#dumpSendPacketDownstreamAvgInfoAsJson #3630
Conversation
…dumpSendPacketDownstreamAvgInfoAsJson
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need synchronized here? Its super class is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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();
...
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether the synchronized is needed in here, the rest of part look good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💔 -1 overall
This message was automatically generated. |
@haiyang1987 Thanks for contribution. @AlphaGouGe @tomscut Thanks for review! |
This change has introduced a findbugs warning on trunk, which was in the build above:
I wonder if the snapshot method needs synchronised to avoid this? We cannot make |
or spotbugs has its rule changed. |
I don't think the rules changed. The final CI report on this PR has the new problem present, so I'm pretty sure this one introduced it. |
Revert this PR and investigate the findbugs warning. |
In the tests setRecordValidityMs method is set synchronized
So consider the snapshot method use recordValidityMs needs synchronised to avoid spotbugs warning " Unsynchronized access" ? |
@haiyang1987 Thanks for your explanation. I think you are right, you can raise a New PR. |
…dumpSendPacketDownstreamAvgInfoAsJson (apache#3630)
…Metrics#dumpSendPacketDownstreamAvgInfoAsJson (apache#3630)" (apache#3697)
Description of PR
As HADOOP-16947 problem with description.
Stale SumAndCount also should be remove when DataNodePeerMetrics#dumpSendPacketDownstreamAvgInfoAsJson.
Ensure the DataNode JMX get SendPacketDownstreamAvgInfo Metrics is accurate.
Details: HADOOP-17995