-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29363: CompactSplit should not attempt to split secondary region replicas #7048
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import java.util.function.IntSupplier; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
| import org.apache.hadoop.hbase.conf.ConfigurationManager; | ||
| import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver; | ||
| import org.apache.hadoop.hbase.quotas.RegionServerSpaceQuotaManager; | ||
|
|
@@ -90,6 +91,8 @@ public class CompactSplit implements CompactionRequester, PropagatingConfigurati | |
| private volatile ThreadPoolExecutor longCompactions; | ||
| private volatile ThreadPoolExecutor shortCompactions; | ||
| private volatile ThreadPoolExecutor splits; | ||
| // Used in unit testing | ||
| private int splitCounter; | ||
|
|
||
| private volatile ThroughputController compactionThroughputController; | ||
| private volatile Set<String> underCompactionStores = ConcurrentHashMap.newKeySet(); | ||
|
|
@@ -112,6 +115,8 @@ public class CompactSplit implements CompactionRequester, PropagatingConfigurati | |
| // compaction throughput controller | ||
| this.compactionThroughputController = | ||
| CompactionThroughputControllerFactory.create(server, conf); | ||
|
|
||
| this.splitCounter = 0; | ||
| } | ||
|
|
||
| // only for test | ||
|
|
@@ -205,7 +210,7 @@ public synchronized boolean requestSplit(final Region r) { | |
| // continuously growing, as well as the number of store files, see HBASE-26242. | ||
| HRegion hr = (HRegion) r; | ||
| try { | ||
| if (shouldSplitRegion() && hr.getCompactPriority() >= PRIORITY_USER) { | ||
| if (shouldSplitRegion(r.getRegionInfo()) && hr.getCompactPriority() >= PRIORITY_USER) { | ||
| byte[] midKey = hr.checkSplit().orElse(null); | ||
| if (midKey != null) { | ||
| requestSplit(r, midKey); | ||
|
|
@@ -235,6 +240,7 @@ private synchronized void requestSplit(final Region r, byte[] midKey, User user) | |
| } | ||
| try { | ||
| this.splits.execute(new SplitRequest(r, midKey, this.server, user)); | ||
| splitCounter += 1; | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug("Splitting " + r + ", " + this); | ||
| } | ||
|
|
@@ -503,12 +509,13 @@ public int getSplitQueueSize() { | |
| return splits.getQueue().size(); | ||
| } | ||
|
|
||
| private boolean shouldSplitRegion() { | ||
| private boolean shouldSplitRegion(RegionInfo ri) { | ||
| if (server.getNumberOfOnlineRegions() > 0.9 * regionSplitLimit) { | ||
| LOG.warn("Total number of regions is approaching the upper limit " + regionSplitLimit + ". " | ||
| + "Please consider taking a look at http://hbase.apache.org/book.html#ops.regionmgt"); | ||
| } | ||
| return (regionSplitLimit > server.getNumberOfOnlineRegions()); | ||
| return (regionSplitLimit > server.getNumberOfOnlineRegions() | ||
| && ri.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID); | ||
|
Contributor
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. This is the key change, every other part of this PR is just unit testing
|
||
| } | ||
|
|
||
| /** Returns the regionSplitLimit */ | ||
|
|
@@ -807,6 +814,11 @@ protected int getSplitThreadNum() { | |
| return this.splits.getCorePoolSize(); | ||
| } | ||
|
|
||
| /** Exposed for unit testing */ | ||
| int getSplitCounter() { | ||
| return splitCounter; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
|
|
||
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.
Is it possible to not introduce field in normal code which is only used for testing?
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.
Yes, done