You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2023/01/11 14:05:40 UTC

[GitHub] [hbase] ndimiduk commented on a diff in pull request #4954: HBASE-27563 ChaosMonkey sometimes generates invalid boundaries for random item selection

ndimiduk commented on code in PR #4954:
URL: https://github.com/apache/hbase/pull/4954#discussion_r1067031749


##########
hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/monkies/PolicyBasedChaosMonkey.java:
##########
@@ -116,13 +116,13 @@ public static <T> T selectWeightedRandomItem(List<Pair<T, Integer>> items) {
 
   /** Selects and returns ceil(ratio * items.length) random items from the given array */
   public static <T> List<T> selectRandomItems(T[] items, float ratio) {
-    int selectedNumber = (int) Math.ceil(items.length * ratio);
-
-    List<T> originalItems = Arrays.asList(items);
+    final int selectedNumber = (int) Math.ceil(items.length * ratio);
+    final List<T> originalItems = Arrays.asList(items);
     Collections.shuffle(originalItems);
-
-    int startIndex = ThreadLocalRandom.current().nextInt(items.length - selectedNumber);
-    return originalItems.subList(startIndex, startIndex + selectedNumber);
+    final int startIndex =

Review Comment:
   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)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org