-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29644: Refresh_meta triggering compaction on user table #7385
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
Open
sharmaar12
wants to merge
1
commit into
apache:HBASE-29081
Choose a base branch
from
sharmaar12:meta_compaction
base: HBASE-29081
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−1
Open
Changes from all commits
Commits
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
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
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
87 changes: 87 additions & 0 deletions
87
...e-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactSplitReadOnly.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,87 @@ | ||
| /* | ||
| * 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.regionserver; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
| import java.io.IOException; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker; | ||
| import org.apache.hadoop.hbase.security.User; | ||
| import org.apache.hadoop.hbase.testclassification.RegionServerTests; | ||
| import org.apache.hadoop.hbase.testclassification.SmallTests; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
|
|
||
| @Category({ RegionServerTests.class, SmallTests.class }) | ||
| public class TestCompactSplitReadOnly { | ||
|
|
||
| private CompactSplit compactSplit; | ||
| private Configuration conf; | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| conf = new Configuration(); | ||
| // enable read-only mode | ||
| conf.setBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY, true); | ||
| // create CompactSplit with conf-only constructor (available for tests) | ||
| compactSplit = new CompactSplit(conf); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() { | ||
| // ensure thread pools are shutdown to avoid leakage | ||
| compactSplit.interruptIfNecessary(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRequestSystemCompactionIgnoredWhenReadOnly() throws IOException { | ||
| // Mock HRegion and HStore minimal behavior | ||
| HRegion region = mock(HRegion.class); | ||
| HStore store = mock(HStore.class); | ||
|
|
||
| // Ensure compaction queues start empty | ||
| assertEquals(0, compactSplit.getCompactionQueueSize()); | ||
|
|
||
| // Call requestSystemCompaction for a single store (selectNow = false) | ||
| compactSplit.requestSystemCompaction(region, store, "test-readonly"); | ||
|
|
||
| // Because read-only mode is enabled, no compaction should be queued | ||
| assertEquals(0, compactSplit.getCompactionQueueSize()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSelectCompactionIgnoredWhenReadOnly() throws IOException { | ||
| HRegion region = mock(HRegion.class); | ||
| HStore store = mock(HStore.class); | ||
|
|
||
| // Ensure compaction queues start empty | ||
| assertEquals(0, compactSplit.getCompactionQueueSize()); | ||
|
|
||
| // Call requestCompaction which uses selectNow = true and should call selectCompaction | ||
| compactSplit.requestCompaction(region, store, "test-select-readonly", 0, | ||
| CompactionLifeCycleTracker.DUMMY, (User) null); | ||
|
|
||
| // Because read-only mode is enabled, selectCompaction should be skipped and no task queued | ||
| assertEquals(0, compactSplit.getCompactionQueueSize()); | ||
| } | ||
| } |
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.
Why we don't simply disable compaction altogether in the read replica cluster? See line #343 in CompactionSplit, there's already a check for compaction enabled flag. I would rather refrain from polluting CompactiSplit code with logic for read replica.
Uh oh!
There was an error while loading. Please reload this page.
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.
We can use that approach but then one issue I can think of is that
hbase.global.readonly.enabledproperty is dynamically configurable using update_all_config but is it true forhbase.hstore.compaction.enabledalso?Uh oh!
There was an error while loading. Please reload this page.
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 like @wchevreuil 's idea.
How about adding the read-only check to the getter?
You don't need to dynamically change the compaction flag.
wdyt?
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.
Then we may need to at least modify the log messages to mention that either compaction is disabled or readonly mode is on. Otherwise compaction may be enabled but we are logging it as disabled because of read-only mode.
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.
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.
or just leave it as is, not a biggy
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.
The actual property name is
hbase.regionserver.compaction.enabled. Compaction is actual "switchable" via the Admin.compactionSwitch() method (we also expose an hbase shell command for that). The CompactSplit thread itself exposes a switchCompaction method which could be called on both RS startup and the dynamic config handler for thehbase.global.readonly.enabledproperty.Uh oh!
There was an error while loading. Please reload this page.
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.
Be careful with switching the property directly. User might have intentionally disabled it and you should not enable it when go from R/O -> R/W mode. My approach seems safer to me.
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.
Good point. Let's just do all checks inside
isCompactionsEnabled, as @anmolnar suggested.