HBASE-27758 Inconsistent synchronization in MetricsUserSourceImpl (#5149)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Bryan Beaudreault 2023-03-31 08:10:58 -04:00 committed by GitHub
parent e5620e26a2
commit 143e9b4ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 20 deletions

View File

@ -137,16 +137,14 @@ public class MetricsUserSourceImpl implements MetricsUserSource {
@Override
public void register() {
synchronized (this) {
getHisto = registry.newTimeHistogram(userGetKey);
scanTimeHisto = registry.newTimeHistogram(userScanTimeKey);
putHisto = registry.newTimeHistogram(userPutKey);
deleteHisto = registry.newTimeHistogram(userDeleteKey);
incrementHisto = registry.newTimeHistogram(userIncrementKey);
appendHisto = registry.newTimeHistogram(userAppendKey);
replayHisto = registry.newTimeHistogram(userReplayKey);
blockBytesScannedCount = registry.newCounter(userBlockBytesScannedKey, "", 0);
}
getHisto = registry.newTimeHistogram(userGetKey);
scanTimeHisto = registry.newTimeHistogram(userScanTimeKey);
putHisto = registry.newTimeHistogram(userPutKey);
deleteHisto = registry.newTimeHistogram(userDeleteKey);
incrementHisto = registry.newTimeHistogram(userIncrementKey);
appendHisto = registry.newTimeHistogram(userAppendKey);
replayHisto = registry.newTimeHistogram(userReplayKey);
blockBytesScannedCount = registry.newCounter(userBlockBytesScannedKey, "", 0);
}
@Override
@ -162,16 +160,14 @@ public class MetricsUserSourceImpl implements MetricsUserSource {
LOG.debug("Removing user Metrics for user: " + user);
}
synchronized (this) {
registry.removeMetric(userGetKey);
registry.removeMetric(userScanTimeKey);
registry.removeMetric(userPutKey);
registry.removeMetric(userDeleteKey);
registry.removeMetric(userIncrementKey);
registry.removeMetric(userAppendKey);
registry.removeMetric(userReplayKey);
registry.removeMetric(userBlockBytesScannedKey);
}
registry.removeMetric(userGetKey);
registry.removeMetric(userScanTimeKey);
registry.removeMetric(userPutKey);
registry.removeMetric(userDeleteKey);
registry.removeMetric(userIncrementKey);
registry.removeMetric(userAppendKey);
registry.removeMetric(userReplayKey);
registry.removeMetric(userBlockBytesScannedKey);
}
@Override