This is an automated email from the ASF dual-hosted git repository.

bbeaudreault pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 897fcf8f2c2 HBASE-28105 NPE in QuotaCache if Table is dropped from 
cluster (#5426)
897fcf8f2c2 is described below

commit 897fcf8f2c228cb41ef716b87a180c1c3968e4bd
Author: Ke Han <38852697+hanke...@users.noreply.github.com>
AuthorDate: Mon Sep 25 13:05:54 2023 -0400

    HBASE-28105 NPE in QuotaCache if Table is dropped from cluster (#5426)
    
    Signed-off-by: Bryan Beaudreault <bbeaudrea...@apache.org>
---
 .../org/apache/hadoop/hbase/quotas/QuotaCache.java | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaCache.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaCache.java
index c8839ad61d1..41f8ad86af4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaCache.java
@@ -373,19 +373,24 @@ public class QuotaCache implements Stoppable {
 
       // Update table machine quota factors
       for (TableName tableName : tableQuotaCache.keySet()) {
-        double factor = 1;
-        try {
-          long regionSize = 
tableRegionStatesCount.get(tableName).getOpenRegions();
-          if (regionSize == 0) {
-            factor = 0;
-          } else {
-            int localRegionSize = rsServices.getRegions(tableName).size();
-            factor = 1.0 * localRegionSize / regionSize;
+        if (tableRegionStatesCount.containsKey(tableName)) {
+          double factor = 1;
+          try {
+            long regionSize = 
tableRegionStatesCount.get(tableName).getOpenRegions();
+            if (regionSize == 0) {
+              factor = 0;
+            } else {
+              int localRegionSize = rsServices.getRegions(tableName).size();
+              factor = 1.0 * localRegionSize / regionSize;
+            }
+          } catch (IOException e) {
+            LOG.warn("Get table regions failed: {}", tableName, e);
           }
-        } catch (IOException e) {
-          LOG.warn("Get table regions failed: {}", tableName, e);
+          tableMachineQuotaFactors.put(tableName, factor);
+        } else {
+          // TableName might have already been dropped (outdated)
+          tableMachineQuotaFactors.remove(tableName);
         }
-        tableMachineQuotaFactors.put(tableName, factor);
       }
     }
   }

Reply via email to