-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-27496 Optionally limit the cumulative size of normalization plans produced by SimpleRegionNormalizer #4888
HBASE-27496 Optionally limit the cumulative size of normalization plans produced by SimpleRegionNormalizer #4888
Conversation
…by SimpleRegionNormalizer This commit adds two new settings: - hbase.normalizer.merge.plans_size_limit.mb - hbase.normalizer.split.plans_size_limit.mb These settings limit the number of plans produced by a single run of SimpleRegionNormalizer, by forcing it to stop producing new plans once the cumulative region size limits are exceeded.
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
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.
You might need to run mvn spotless:apply if you haven't already. There were also some checkstyle warnings before that need to be addressed if they're still applicable.
Otherwise just 2 small requests. Thanks!
@@ -607,6 +609,39 @@ public void testNormalizerCannotMergeNonAdjacentRegions() { | |||
assertThat(plans, empty()); | |||
} | |||
|
|||
@Test | |||
public void testMergeSizeLimit() { |
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.
Can you add a test for the shuffle stuff? Just proving that the limit doesn't starve merges like we hope
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 can write a test but it will be flaky and fail sometimes through bad luck. Collections.shuffle()
is not guaranteed to actually change item ordering.
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 decided that it was important that the limit be applied approximately fairly to splits and merges. Given that decision, we decided to design our implementation for that goal in mind. Since HBase is an open source project, someone could easily accidentally break this decision down the line. The way to prevent that is be creating tests based on the goals of the code change. Since this was a specific goal, we should probably guard it with a test. The comment helps but isn't really a contract and is often overlooked.
There's a lot of mocking going on in here. It seems like we could think of a way to make a non-flaky test despite the randomness. We aren't testing for a perfect shuffle, we really just want to ensure that at least 1 merge gets into the plan to prove that we aren't starving that.
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.
Added a test
for (NormalizationPlan plan : plans) { | ||
cumulativeSizeMb += plan.getPlanSizeMb(); | ||
if (cumulativeSizeMb < normalizerConfiguration.getCumulativePlansSizeLimitMb()) { | ||
maybeTruncatedPlans.add(plan); |
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.
Could you move this down a line and instead have this if block return early? Will just cut a little cpu when there are very large plans
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.
Done
@@ -229,6 +231,8 @@ public List<NormalizationPlan> computePlansForTable(final TableDescriptor tableD | |||
plans.addAll(mergePlans); | |||
} | |||
|
|||
plans = truncateForSize(plans); |
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.
My only other thought is whether it makes sense to do the truncating in the NormalizationWorker, like how it currently handles rate limiting
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 difference there is that the new setting would apply to HBase clusters using alternate RegionNormalizer
implementations. I really don't know if that's a pro or a con.
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.
Yea, to me the separation of concerns makes sense -- RegionNormalizer generates plans, RegionNormalizerWorker executes those plans based on limits (rate limit and max work limit). The default is unlimited, so even if someone is using their own RegionNormalizer and didn't want limits, they wouldn't get them. But we'd be making the configuration available to all users, which seems like a win with no real downside (given default).
That said, if we decided to keep the shuffling i think that makes sense for SimpleRegionNormalizer to do -- return a shuffled list, rather than have RegionNormalizerWorker shuffle. The shuffling seems ok for the simple normalizer but would probably be unexpected for other implementations.
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.
Sure, I've moved the truncation into RegionNormalizerWorker
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
21240f6
to
7c2025b
Compare
🎊 +1 overall
This message was automatically generated. |
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.
cool, a few more small comments and then i think we're good to go. just logging/config fixes
...e-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java
Show resolved
Hide resolved
...e-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
Outdated
Show resolved
Hide resolved
...e-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
Show resolved
Hide resolved
...e-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/RegionNormalizerWorker.java
Outdated
Show resolved
Hide resolved
...e-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java
Outdated
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
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.
looks good, thanks! i'll merge once the 3 pre-commits all come back green
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
The test failures look unrelated but unfortunately we do have to fix the checkstyle issue. Running spotless:apply may fix it. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…alizer (apache#4888) Signed-off-by: Bryan Beaudreault <[email protected]>
…alizer (#4888) Signed-off-by: Bryan Beaudreault <[email protected]>
…alizer (#4888) Signed-off-by: Bryan Beaudreault <[email protected]>
…ecuted in the Normalizer (apache#4888) Signed-off-by: Bryan Beaudreault <[email protected]>
This PR adds the new setting
hbase.normalizer.plans_size_limit.mb
. This setting limit the number of plans processed by RegionNormalizerWorker, by forcing it to stop processing plans once the cumulative region size limits are exceeded.