Skip to content

HBASE-27563 ChaosMonkey sometimes generates invalid boundaries for random item selection - #4954

Merged
ndimiduk merged 1 commit into
apache:masterfrom
ndimiduk:27563-chaosmonkey-invalid-boundaries
Jan 12, 2023
Merged

HBASE-27563 ChaosMonkey sometimes generates invalid boundaries for random item selection#4954
ndimiduk merged 1 commit into
apache:masterfrom
ndimiduk:27563-chaosmonkey-invalid-boundaries

Conversation

@ndimiduk

Copy link
Copy Markdown
Member

Clamp the boundaries of the selected sublist according to the input list size.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.


int startIndex = ThreadLocalRandom.current().nextInt(items.length - selectedNumber);
return originalItems.subList(startIndex, startIndex + selectedNumber);
final int startIndex =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem here is ratio could be greater than 1.0?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems so... and it looks like this patch is not sufficient. Here's the stack trace from branch-2.5.

2023-01-10T19:33:35,651 WARN [ChaosMonkey-0] policies.Policy: Exception occurred during performing action: java.lang.IllegalArgumentException: bound must be positive
at java.base/java.util.Random.nextInt(Random.java:322)
at java.base/java.util.concurrent.ThreadLocalRandom.nextInt(ThreadLocalRandom.java:449)
at org.apache.hadoop.hbase.chaos.monkies.PolicyBasedChaosMonkey.selectRandomItems(PolicyBasedChaosMonkey.java:123)
at org.apache.hadoop.hbase.chaos.actions.RollingBatchRestartRsAction.selectServers(RollingBatchRestartRsAction.java:130)
at org.apache.hadoop.hbase.chaos.actions.RollingBatchRestartRsAction.perform(RollingBatchRestartRsAction.java:75)
at org.apache.hadoop.hbase.chaos.policies.DoActionsOncePolicy.runOneIteration(DoActionsOncePolicy.java:48)
at org.apache.hadoop.hbase.chaos.policies.PeriodicPolicy.run(PeriodicPolicy.java:41)
at org.apache.hadoop.hbase.chaos.policies.CompositeSequentialPolicy.run(CompositeSequentialPolicy.java:42)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more likely that I have ratio == length, we'll have this problem... Let me add some debugging and see what I can learn.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd better add some comments here to say why we need these guards? Is it because of the floating point precision?

@Apache9

Copy link
Copy Markdown
Contributor

Checked the code, the ratio is percentage of regionservers we want to restart, normally, so in general it should be a value between 0 and 1. But there is no sanity check in our code...

@ndimiduk

Copy link
Copy Markdown
MemberAuthor
2023-01-11T15:39:46,370 DEBUG [ChaosMonkey-0] monkies.PolicyBasedChaosMonkey: selectRandomItems(10, 1.0) of type class [Lorg.apache.hadoop.hbase.ServerName;

@ndimiduk

Copy link
Copy Markdown
MemberAuthor

We have 1.0f as default ratio values for a couple constants in MonkeyConstants.java.

@ndimiduk

Copy link
Copy Markdown
MemberAuthor

This code handles the ratio=1.0 case correctly.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.


List<T> originalItems = Arrays.asList(items);
final int selectedNumber = (int) Math.ceil(items.length * ratio);
final List<T> originalItems = Arrays.asList(items);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrays.asList will create a ArrayList which is backed by the given array, so the later shuffle will change the order of the items array which is passed in as a parameter. If we think this is acceptable, we can just shuffle on the given array instead of wrapping it? If not, I think we should copy the array.


int startIndex = ThreadLocalRandom.current().nextInt(items.length - selectedNumber);
return originalItems.subList(startIndex, startIndex + selectedNumber);
if (selectedNumber == items.length) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use >= for safety?


int startIndex = ThreadLocalRandom.current().nextInt(items.length - selectedNumber);
return originalItems.subList(startIndex, startIndex + selectedNumber);
final int startIndex =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd better add some comments here to say why we need these guards? Is it because of the floating point precision?

@ndimiduk

Copy link
Copy Markdown
MemberAuthor

Good points all around, thanks @Apache9

public void waitForStop() throws InterruptedException {
monkeyThreadPool.awaitTermination(1, TimeUnit.MINUTES);
if (!monkeyThreadPool.awaitTermination(1, TimeUnit.MINUTES)) {
LOG.warn("Some pool threads failed to terminate, {}", monkeyThreadPool);

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. monkeyThreadPool is not a daemon pool, so if this termination fails for some reason, the process can hang. Let me add a forced shutdown.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.

@Apache-HBase

This comment was marked as outdated.

final int startIndex =
Math.max(0, ThreadLocalRandom.current().nextInt(items.length - selectedNumber));
final int endIndex = Math.min(items.length, startIndex + selectedNumber);
return shuffledItems.subList(startIndex, endIndex);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here you could make use of org.apache.hadoop.hbase.util.ReservoirSample so we do not need to copy the whole array? Not a blocker issue anyway.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's simpler.

@ndimiduk
ndimidukforce-pushed the 27563-chaosmonkey-invalid-boundaries branch from 5ea901a to 00ca430CompareJanuary 12, 2023 14:44
…ndom item selection
Signed-off-by: Duo Zhang <zhangduo@apache.org>
@ndimiduk
ndimidukforce-pushed the 27563-chaosmonkey-invalid-boundaries branch from 00ca430 to b02e312CompareJanuary 12, 2023 14:46
@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 38sDocker mode activated.
-0 ⚠️yetus0m 4sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall1m 58smaster passed
+1 💚compile0m 14smaster passed
+1 💚shadedjars3m 58sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 9smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 3sthe patch passed
+1 💚compile0m 16sthe patch passed
+1 💚javac0m 16sthe patch passed
+1 💚shadedjars4m 1spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 9sthe patch passed
_ Other Tests _
+1 💚unit0m 35shbase-it in the patch passed.
15m 11s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/artifact/yetus-jdk8-hadoop3-check/output/Dockerfile
GITHUB PR#4954
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 2c34d0b3d4f3 5.4.0-1088-aws #96~18.04.1-Ubuntu SMP Mon Oct 17 02:57:48 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaTemurin-1.8.0_352-b08
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/testReport/
Max. process+thread count561 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 39sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall3m 3smaster passed
+1 💚compile0m 18smaster passed
+1 💚shadedjars4m 15sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 11smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 37sthe patch passed
+1 💚compile0m 18sthe patch passed
+1 💚javac0m 18sthe patch passed
+1 💚shadedjars4m 20spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 11sthe patch passed
_ Other Tests _
+1 💚unit0m 36shbase-it in the patch passed.
17m 32s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR#4954
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 23bfc1180327 5.4.0-1092-aws #100~18.04.2-Ubuntu SMP Tue Nov 29 08:39:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaEclipse Adoptium-11.0.17+8
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/testReport/
Max. process+thread count584 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 8sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ master Compile Tests _
+1 💚mvninstall2m 32smaster passed
+1 💚compile0m 27smaster passed
+1 💚checkstyle0m 10smaster passed
+1 💚spotless0m 40sbranch has no errors when running spotless:check.
+1 💚spotbugs0m 22smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 32sthe patch passed
+1 💚compile0m 26sthe patch passed
+1 💚javac0m 26sthe patch passed
+1 💚checkstyle0m 11sthe patch passed
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚hadoopcheck8m 44sPatch does not cause any errors with Hadoop 3.2.4 3.3.4.
+1 💚spotless0m 40spatch has no errors when running spotless:check.
+1 💚spotbugs0m 30sthe patch passed
_ Other Tests _
+1 💚asflicense0m 10sThe patch does not generate ASF License warnings.
24m 23s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#4954
Optional Testsdupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
unameLinux 1bbcf7845206 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaEclipse Adoptium-11.0.17+8
Max. process+thread count79 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/4/console
versionsgit=2.34.1 maven=3.8.6 spotbugs=4.7.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 39sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall2m 35smaster passed
+1 💚compile0m 17smaster passed
+1 💚shadedjars4m 11sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 10smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 33sthe patch passed
+1 💚compile0m 17sthe patch passed
+1 💚javac0m 17sthe patch passed
+1 💚shadedjars4m 12spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 11sthe patch passed
_ Other Tests _
+1 💚unit0m 36shbase-it in the patch passed.
16m 52s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR#4954
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 17893de185d8 5.4.0-1092-aws #100~18.04.2-Ubuntu SMP Tue Nov 29 08:39:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaEclipse Adoptium-11.0.17+8
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/testReport/
Max. process+thread count594 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec0m 38sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall2m 2smaster passed
+1 💚compile0m 15smaster passed
+1 💚shadedjars10m 12sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 10smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 45sthe patch passed
+1 💚compile0m 15sthe patch passed
+1 💚javac0m 15sthe patch passed
+1 💚shadedjars4m 11spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 11sthe patch passed
_ Other Tests _
+1 💚unit0m 43shbase-it in the patch passed.
22m 29s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/artifact/yetus-jdk8-hadoop3-check/output/Dockerfile
GITHUB PR#4954
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 9f8ea032e44e 5.4.0-1088-aws #96~18.04.1-Ubuntu SMP Mon Oct 17 02:57:48 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaTemurin-1.8.0_352-b08
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/testReport/
Max. process+thread count556 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/console
versionsgit=2.34.1 maven=3.8.6
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 21sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ master Compile Tests _
+1 💚mvninstall3m 2smaster passed
+1 💚compile0m 31smaster passed
+1 💚checkstyle0m 12smaster passed
+1 💚spotless0m 48sbranch has no errors when running spotless:check.
+1 💚spotbugs0m 28smaster passed
_ Patch Compile Tests _
+1 💚mvninstall3m 11sthe patch passed
+1 💚compile0m 38sthe patch passed
+1 💚javac0m 38sthe patch passed
+1 💚checkstyle0m 12sthe patch passed
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚hadoopcheck12m 8sPatch does not cause any errors with Hadoop 3.2.4 3.3.4.
+1 💚spotless0m 55spatch has no errors when running spotless:check.
+1 💚spotbugs0m 38sthe patch passed
_ Other Tests _
+1 💚asflicense0m 9sThe patch does not generate ASF License warnings.
32m 8s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#4954
Optional Testsdupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
unameLinux b65c4417fd20 5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / dff8e50
Default JavaEclipse Adoptium-11.0.17+8
Max. process+thread count84 (vs. ulimit of 30000)
modulesC: hbase-it U: hbase-it
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4954/5/console
versionsgit=2.34.1 maven=3.8.6 spotbugs=4.7.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@ndimiduk
ndimiduk merged commit 2a7c69d into apache:masterJan 12, 2023
@ndimiduk
ndimiduk deleted the 27563-chaosmonkey-invalid-boundaries branch January 12, 2023 16:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ndimiduk@Apache-HBase@Apache9