Skip to content

Commit

Permalink
HBASE-27758 Inconsistent synchronization in MetricsUserSourceImpl (#5149
Browse files Browse the repository at this point in the history
)

Signed-off-by: Duo Zhang <[email protected]>
  • Loading branch information
bbeaudreault authored Mar 31, 2023
1 parent e5620e2 commit 143e9b4
Showing 1 changed file with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,14 @@ public MetricsUserSourceImpl(String user, MetricsUserAggregateSourceImpl agg) {

@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
Expand All @@ -162,16 +160,14 @@ public void deregister() {
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
Expand Down

0 comments on commit 143e9b4

Please sign in to comment.