smengcl commented on code in PR #10988:
URL: https://github.com/apache/ozone/pull/10988#discussion_r3755439599
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/MutableVolumeSet.java:
##########
@@ -421,6 +432,36 @@ public StorageLocationReport[] getStorageReport() {
}
}
+ /**
+ * Lock-free variant of {@link #getStorageReport()}. Both {@code volumeMap}
+ * and {@code failedVolumeMap} are {@link ConcurrentHashMap}s, so this
returns
+ * a weakly-consistent snapshot (mirroring {@link #getVolumesList()}) without
+ * acquiring the volume-set lock.
+ *
+ * <p>Use this from callers that must not block on the volume-set lock. In
+ * particular, metrics sampling runs while the {@code DefaultMetricsSystem}
+ * monitor is held, and a volume-failure handler holds the volume-set write
+ * lock while unregistering volume metrics (which needs that same monitor);
+ * acquiring the volume-set lock from the sampling thread can therefore
+ * deadlock the whole metrics system.
+ */
+ public StorageLocationReport[] getStorageReportSnapshot() {
+ // No lock is held, so the map sizes can change concurrently; collect into
a
+ // list instead of indexing into a pre-sized array.
+ List<StorageLocationReport> reports = new ArrayList<>(volumeMap.size() +
failedVolumeMap.size());
Review Comment:
done
--
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]