-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29005 Cannot split hbase:quota table when quota enforcement is enabled #6501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
hbase-server/src/test/java/org/apache/hadoop/hbase/TestSplitMergeQuotaTable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hbase; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.TimeUnit; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.client.AsyncAdmin; | ||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
| import org.apache.hadoop.hbase.quotas.QuotaUtil; | ||
| import org.apache.hadoop.hbase.testclassification.LargeTests; | ||
| import org.apache.hadoop.hbase.testclassification.MiscTests; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.junit.rules.ExternalResource; | ||
| import org.junit.rules.RuleChain; | ||
| import org.junit.rules.TestRule; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.Parameterized; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Test that we can split and merge the quota table given the presence of various configuration | ||
| * settings. | ||
| */ | ||
| @Category({ MiscTests.class, LargeTests.class }) | ||
| @RunWith(Parameterized.class) | ||
| public class TestSplitMergeQuotaTable { | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(TestSplitMergeQuotaTable.class); | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestSplitMergeQuotaTable.class); | ||
|
|
||
| @Parameterized.Parameters(name = "{1}") | ||
| public static Object[][] params() { | ||
| return new Object[][] { { Map.of(QuotaUtil.QUOTA_CONF_KEY, "false") }, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing both with and without the quotas feature enabled, so that we have confidence that someone who has temporarily disabled the feature is still able to operate on the table. |
||
| { Map.of(QuotaUtil.QUOTA_CONF_KEY, "true") }, }; | ||
| } | ||
|
|
||
| private final TableName tableName = QuotaUtil.QUOTA_TABLE_NAME; | ||
| private final MiniClusterRule miniClusterRule; | ||
|
|
||
| @Rule | ||
| public final RuleChain ruleChain; | ||
|
|
||
| public TestSplitMergeQuotaTable(Map<String, String> configMap) { | ||
| this.miniClusterRule = MiniClusterRule.newBuilder().setConfiguration(() -> { | ||
| Configuration conf = HBaseConfiguration.create(); | ||
| conf.setInt(HConstants.HBASE_CLIENT_META_OPERATION_TIMEOUT, 1000); | ||
| conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2); | ||
| configMap.forEach(conf::set); | ||
| return conf; | ||
| }).build(); | ||
| TestRule ensureQuotaTableRule = new ExternalResource() { | ||
| @Override | ||
| protected void before() throws Throwable { | ||
| if ( | ||
| !miniClusterRule.getTestingUtility().getAsyncConnection().getAdmin() | ||
| .tableExists(QuotaUtil.QUOTA_TABLE_NAME).get(30, TimeUnit.SECONDS) | ||
| ) { | ||
| miniClusterRule.getTestingUtility().getHBaseCluster().getMaster() | ||
| .createSystemTable(QuotaUtil.QUOTA_TABLE_DESC); | ||
| } | ||
| } | ||
| }; | ||
| this.ruleChain = RuleChain.outerRule(miniClusterRule).around(ensureQuotaTableRule); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSplitMerge() throws Exception { | ||
| HBaseTestingUtil util = miniClusterRule.getTestingUtility(); | ||
| util.waitTableAvailable(tableName, 30_000); | ||
| AsyncAdmin admin = util.getAsyncConnection().getAdmin(); | ||
| admin.split(tableName, Bytes.toBytes(0x10)).get(30, TimeUnit.SECONDS); | ||
| util.waitFor(30_000, new Waiter.ExplainingPredicate<Exception>() { | ||
|
|
||
| @Override | ||
| public boolean evaluate() throws Exception { | ||
| // can potentially observe the parent and both children via this interface. | ||
| return admin.getRegions(tableName) | ||
| .thenApply(val -> val.stream() | ||
| .filter(info -> info.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID).toList()) | ||
| .get(30, TimeUnit.SECONDS).size() > 1; | ||
| } | ||
|
|
||
| @Override | ||
| public String explainFailure() { | ||
| return "Split has not finished yet"; | ||
| } | ||
| }); | ||
| util.waitUntilNoRegionsInTransition(); | ||
| List<RegionInfo> regionInfos = admin.getRegions(tableName) | ||
| .thenApply(val -> val.stream() | ||
| .filter(info -> info.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID).toList()) | ||
| .get(30, TimeUnit.SECONDS); | ||
| assertEquals(2, regionInfos.size()); | ||
| LOG.info("{}", regionInfos); | ||
| admin.mergeRegions(regionInfos.stream().map(RegionInfo::getRegionName).toList(), false).get(30, | ||
| TimeUnit.SECONDS); | ||
| util.waitFor(30000, new Waiter.ExplainingPredicate<Exception>() { | ||
|
|
||
| @Override | ||
| public boolean evaluate() throws Exception { | ||
| // can potentially observe the parent and both children via this interface. | ||
| return admin.getRegions(tableName) | ||
| .thenApply(val -> val.stream() | ||
| .filter(info -> info.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID).toList()) | ||
| .get(30, TimeUnit.SECONDS).size() == 1; | ||
| } | ||
|
|
||
| @Override | ||
| public String explainFailure() { | ||
| return "Merge has not finished yet"; | ||
| } | ||
| }); | ||
| assertEquals(1, admin.getRegions(tableName).get(30, TimeUnit.SECONDS).size()); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reduced scope of this test class to just cover the quota table. Previously It was for system tables and on branch-2 I was adding coverage for the namespace table. Turns out that we hard-code cannot split the namespace table, so that was futile.