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
  • Loading branch information
chandrasekhar-188k committed Feb 17, 2024
1 parent d925754 commit 76ccf0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2726,16 +2726,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 hbase:quota table, see:
// https://issues.apache.org/jira/browse/HBASE-28183
if (!tableName.equals(QuotaUtil.QUOTA_TABLE_NAME)) {
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,16 @@ 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) {
LOG.error("", ex);
fail("Got an exception while enabling table: " + QuotaUtil.QUOTA_TABLE_NAME);
}
}
}

0 comments on commit 76ccf0a

Please sign in to comment.