adoroszlai commented on code in PR #6682:
URL: https://github.com/apache/ozone/pull/6682#discussion_r1601538500
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1669,21 +1670,27 @@ public void start() throws IOException {
}
// Set metrics and start metrics back ground thread
- metrics.setNumVolumes(metadataManager.countRowsInTable(metadataManager
- .getVolumeTable()));
- metrics.setNumBuckets(metadataManager.countRowsInTable(metadataManager
- .getBucketTable()));
-
- if (getMetricsStorageFile().exists()) {
- OmMetricsInfo metricsInfo = READER.readValue(getMetricsStorageFile());
- metrics.setNumKeys(metricsInfo.getNumKeys());
- }
+ CompletableFuture.runAsync(() -> {
+ try {
+ metrics.setNumVolumes(
+
metadataManager.countRowsInTable(metadataManager.getVolumeTable()));
+ metrics.setNumBuckets(
+
metadataManager.countRowsInTable(metadataManager.getBucketTable()));
+
+ if (getMetricsStorageFile().exists()) {
+ OmMetricsInfo metricsInfo =
READER.readValue(getMetricsStorageFile());
+ metrics.setNumKeys(metricsInfo.getNumKeys());
+ }
Review Comment:
- This sets `metrics.numKeys` from the file.
- `ScheduleOMMetricsWriteTask` writes `metrics.numKeys` to the file in the
`Timer` thread started below.
Making the initial read from file async introduces a race condition: the two
threads may now run in the wrong order, in which case OM may write 0 to the
file before reading the previous valid value.
--
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]