belliottsmith commented on code in PR #4895:
URL: https://github.com/apache/cassandra/pull/4895#discussion_r3625444598


##########
src/java/org/apache/cassandra/metrics/ThreadLocalMetrics.java:
##########
@@ -374,26 +375,110 @@ static void recycleMetricId(int metricId)
             lock.unlock();
         }
 
-        // there's no an obvious happens-before relation between 
currentCounterValues[metricId] = 0 write we just did
-        // and an initial read of the entry by a thread which updates the 
reused metric
-        // as a workaround we introduce a delay in recyling to provide the 
write visibility in practice
-        //  even if it is not formally guaranteed by the JMM
-        ScheduledExecutors.scheduledTasks.schedule(() -> {
+        freeMetricIdSetTracker.markAsFree(metricId);
+    }
+
+    @VisibleForTesting
+    static class FreeMetricIdSetTracker
+    {
+
+        private final Object freeMetricIdSetGuard = new Object();

Review Comment:
   nit: any reason we don't just use the enclosing class's monitor now it's a 
separate object?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to