You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2024/04/07 14:03:25 UTC

(hbase) branch branch-2.6 updated: HBASE-28183 It's impossible to re-enable the quota table if it gets disabled (#5691)

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

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


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

commit 21381882929a00b10972b0d8c1c7c06e5690904b
Author: chandrasekhar-188k <15...@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 <bb...@apache.org>
    Signed-off-by: Pankaj Kumar <pa...@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 4195cc7f3f5..61e3048d9f0 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
@@ -2663,16 +2663,20 @@ public class HMaster extends HRegionServer implements MasterServices {
           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 1f9a016eb98..a3b2929b9aa 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);
+    }
+  }
 }