Skip to content

Commit

Permalink
HBASE-28183 It's impossible to re-enable the quota table if it gets d…
Browse files Browse the repository at this point in the history
…isabled (#5691)

Signed-off-by: Bryan Beaudreault <bbeaudreault@apache.org>
Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
  • Loading branch information
chandrasekhar-188k authored and bbeaudreault committed Apr 7, 2024
1 parent eea740c commit b75fe0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2728,16 +2728,20 @@ protected void run() throws IOException {
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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -994,4 +994,15 @@ public int getQuotaSettingCount(Admin admin) throws IOException {
}
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);
}
}
}

0 comments on commit b75fe0d

Please sign in to comment.