complone commented on code in PR #7306:
URL: https://github.com/apache/hudi/pull/7306#discussion_r1040184209


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/metrics/HoodieLockMetrics.java:
##########
@@ -70,11 +71,13 @@ private String getMetricsName(String metric) {
 
   private Timer createTimerForMetrics(MetricRegistry registry, String metric) {
     String metricName = getMetricsName(metric);
-    synchronized (REGISTRY_LOCK) {
-      if (registry.getMetrics().get(metricName) == null) {
-        lockDuration = new Timer(new SlidingWindowReservoir(keepLastNtimes));
-        registry.register(metricName, lockDuration);
-        return lockDuration;
+    if (registry.getMetrics().get(metricName) == null) {
+      synchronized (Registry.class) {
+        if (registry.getMetrics().get(metricName) == null) {

Review Comment:
   > 为什么`REGISTRY_LOCK`不能在这里正常工作,你能详细解释一下吗?
   
   When using the reentrant lock, the Task threads are isolated from each other 
before, but there will be a situation where the second Task thread enters the 
synchronized scope and waits after the first Task thread registers the value. 
At this time, the metrics may not be obtained. So there is a duplicate 
registration



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to