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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3340d8dd07e HBASE-28183 It's impossible to re-enable the quota table 
if it gets disabled (#5691)
3340d8dd07e is described below

commit 3340d8dd07eba18b71dcc44cd1fa7633ac630a5e
Author: chandrasekhar-188k 
<154109917+chandrasekhar-1...@users.noreply.github.com>
AuthorDate: Sun Apr 7 18:44:06 2024 +0530

    HBASE-28183 It's impossible to re-enable the quota table if it gets 
disabled (#5691)
    
    Signed-off-by: Bryan Beaudreault <bbeaudrea...@apache.org>
    Signed-off-by: Pankaj Kumar <pankajku...@apache.org>
---
 .../org/apache/hadoop/hbase/master/HMaster.java    | 24 +++++++++++++---------
 .../apache/hadoop/hbase/quotas/TestQuotaAdmin.java | 11 ++++++++++
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index ddef3e27b40..0dc5b61cba8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -2728,16 +2728,20 @@ public class HMaster extends 
HBaseServerBase<MasterRpcServices> implements Maste
           MasterQuotaManager quotaManager = getMasterQuotaManager();
           if (quotaManager != null) {
             if (quotaManager.isQuotaInitialized()) {
-              SpaceQuotaSnapshot currSnapshotOfTable =
-                
QuotaTableUtil.getCurrentSnapshotFromQuotaTable(getConnection(), tableName);
-              if (currSnapshotOfTable != null) {
-                SpaceQuotaStatus quotaStatus = 
currSnapshotOfTable.getQuotaStatus();
-                if (
-                  quotaStatus.isInViolation()
-                    && SpaceViolationPolicy.DISABLE == 
quotaStatus.getPolicy().orElse(null)
-                ) {
-                  throw new AccessDeniedException("Enabling the table '" + 
tableName
-                    + "' is disallowed due to a violated space quota.");
+              // skip checking quotas for system tables, see:
+              // https://issues.apache.org/jira/browse/HBASE-28183
+              if (!tableName.isSystemTable()) {
+                SpaceQuotaSnapshot currSnapshotOfTable =
+                  
QuotaTableUtil.getCurrentSnapshotFromQuotaTable(getConnection(), tableName);
+                if (currSnapshotOfTable != null) {
+                  SpaceQuotaStatus quotaStatus = 
currSnapshotOfTable.getQuotaStatus();
+                  if (
+                    quotaStatus.isInViolation()
+                      && SpaceViolationPolicy.DISABLE == 
quotaStatus.getPolicy().orElse(null)
+                  ) {
+                    throw new AccessDeniedException("Enabling the table '" + 
tableName
+                      + "' is disallowed due to a violated space quota.");
+                  }
                 }
               }
             } else if (LOG.isTraceEnabled()) {
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
index c577e9aceac..817f135f0c9 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java
@@ -994,4 +994,15 @@ public class TestQuotaAdmin {
     }
     return quotaSettingCount;
   }
+
+  @Test
+  public void testQuotaTableDisableAndEnable() throws Exception {
+    final Admin admin = TEST_UTIL.getAdmin();
+    admin.disableTable(QuotaUtil.QUOTA_TABLE_NAME);
+    try {
+      admin.enableTable(QuotaUtil.QUOTA_TABLE_NAME);
+    } catch (Exception ex) {
+      fail("Got an exception while enabling table: " + 
QuotaUtil.QUOTA_TABLE_NAME);
+    }
+  }
 }

Reply via email to