From 68d8573c095df107aa0bfb52239c349ee314ff65 Mon Sep 17 00:00:00 2001 From: zhengzhuobinzzb Date: Sat, 18 Dec 2021 23:22:14 +0800 Subject: [PATCH] HBASE-26580 The message of StoreTooBusy is confused (#3949) Signed-off-by: Duo Zhang Reviewed-by: Bryan Beaudreault --- .../throttle/StoreHotnessProtector.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java index f75fb3c848f..4cf0b59c9a2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/throttle/StoreHotnessProtector.java @@ -108,6 +108,8 @@ public class StoreHotnessProtector { } String tooBusyStore = null; + boolean aboveParallelThreadLimit = false; + boolean aboveParallelPrePutLimit = false; for (Map.Entry> e : familyMaps.entrySet()) { Store store = this.region.getStore(e.getKey()); @@ -119,19 +121,19 @@ public class StoreHotnessProtector { //we need to try to add #preparePutCount at first because preparePutToStoreMap will be //cleared when changing the configuration. - preparePutToStoreMap.putIfAbsent(e.getKey(), new AtomicInteger()); - AtomicInteger preparePutCounter = preparePutToStoreMap.get(e.getKey()); - if (preparePutCounter == null) { - preparePutCounter = new AtomicInteger(); - preparePutToStoreMap.putIfAbsent(e.getKey(), preparePutCounter); - } - int preparePutCount = preparePutCounter.incrementAndGet(); - if (store.getCurrentParallelPutCount() > this.parallelPutToStoreThreadLimit - || preparePutCount > this.parallelPreparePutToStoreThreadLimit) { + int preparePutCount = preparePutToStoreMap + .computeIfAbsent(e.getKey(), key -> new AtomicInteger()) + .incrementAndGet(); + boolean storeAboveThread = + store.getCurrentParallelPutCount() > this.parallelPutToStoreThreadLimit; + boolean storeAbovePrePut = preparePutCount > this.parallelPreparePutToStoreThreadLimit; + if (storeAboveThread || storeAbovePrePut) { tooBusyStore = (tooBusyStore == null ? store.getColumnFamilyName() : tooBusyStore + "," + store.getColumnFamilyName()); } + aboveParallelThreadLimit |= storeAboveThread; + aboveParallelPrePutLimit |= storeAbovePrePut; if (LOG.isTraceEnabled()) { LOG.trace(store.getColumnFamilyName() + ": preparePutCount=" + preparePutCount @@ -140,13 +142,16 @@ public class StoreHotnessProtector { } } - if (tooBusyStore != null) { + if (aboveParallelThreadLimit || aboveParallelPrePutLimit) { String msg = "StoreTooBusy," + this.region.getRegionInfo().getRegionNameAsString() + ":" + tooBusyStore - + " Above parallelPutToStoreThreadLimit(" + this.parallelPutToStoreThreadLimit + ")"; - if (LOG.isTraceEnabled()) { - LOG.trace(msg); - } + + " Above " + + (aboveParallelThreadLimit ? "parallelPutToStoreThreadLimit(" + + this.parallelPutToStoreThreadLimit + ")" : "") + + (aboveParallelThreadLimit && aboveParallelPrePutLimit ? " or " : "") + + (aboveParallelPrePutLimit ? "parallelPreparePutToStoreThreadLimit(" + + this.parallelPreparePutToStoreThreadLimit + ")" : ""); + LOG.trace(msg); throw new RegionTooBusyException(msg); } }