You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/08/25 16:26:16 UTC

[GitHub] [pulsar] yuruguo opened a new issue #11775: [pulsar-testclient] --subscriptions size is not equal to --num-subscriptions can cause IndexOutOfBoundsException in consumption

yuruguo opened a new issue #11775:
URL: https://github.com/apache/pulsar/issues/11775


   **Describe the bug**
   --subscriptions size is not equal to --num-subscriptions can cause IndexOutOfBoundsException when execute `bin/pulsar-perf consume`
   
   **To Reproduce**
   Steps to reproduce the behavior:
   **case 1:**
   `bin/pulsar-perf consume -ns 2 -n 1 -st Exclusive -sp Earliest -ss sub -r 100 test01`
   **case 2:**
   `bin/pulsar-perf consume -ns 3 -n 2 -st Share -sp Earliest -ss mysub01,mysub02 -r 100 test01`
                   
   
   **Expected behavior**
   **case 1:**
   22:50:41.638 [main] INFO  org.apache.pulsar.testclient.PerformanceConsumer - Adding 1 consumers per subscription on topic persistent://public/default/test01
   Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
   	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
   	at java.util.ArrayList.get(ArrayList.java:429)
   	at org.apache.pulsar.testclient.PerformanceConsumer.main(PerformanceConsumer.java:369)
   **case 2:**
   23:34:50.050 [main] INFO  org.apache.pulsar.testclient.PerformanceConsumer - Adding 2 consumers per subscription on topic persistent://public/default/test01
   Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
   	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
   	at java.util.ArrayList.get(ArrayList.java:429)
   	at org.apache.pulsar.testclient.PerformanceConsumer.main(PerformanceConsumer.java:369)
   
   **Screenshots**
   **case 1:**
   <img width="1400" alt="WX20210826-001802@2x" src="https://user-images.githubusercontent.com/13013780/130827481-1c21450d-dac8-45e1-814e-1305bcda7140.png">
   **case 2:**
   <img width="1404" alt="22222" src="https://user-images.githubusercontent.com/13013780/130828162-58509b64-c9ea-4742-a005-4b0310c11bfe.png">
   
   **Desktop (please complete the following information):**
    - OS: [Mac]
   
   **Additional context**
   in branch-2.8,releated to code - `org.apache.pulsar.testclient.PerformanceConsumer`
   <img width="937" alt="code" src="https://user-images.githubusercontent.com/13013780/130828421-20cdf2cd-13e4-4184-8406-0635b6f39d8c.png">
   
   


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] yuruguo commented on issue #11775: [pulsar-testclient] --subscriptions size is less than --num-subscriptions can cause IndexOutOfBoundsException in consumption

Posted by GitBox <gi...@apache.org>.
yuruguo commented on issue #11775:
URL: https://github.com/apache/pulsar/issues/11775#issuecomment-906173415


   I think the reason for this problem is related to the following:
   Whether it is exclusive or non-exclusive mode, we need to judge whether `--subscriptions size` and `--num-subscriptions` are equal. But why the code judges `--subscriptions size`  and `--num-consumers` and limits to non-exclusive mode, as follows:
   
   >         // class: org.apache.pulsar.testclient.PerformanceConsumer, line: 226-241
           if (arguments.subscriptionType != SubscriptionType.Exclusive &&
                   arguments.subscriptions != null &&
                   arguments.subscriptions.size() != arguments.numConsumers) {
               // keep compatibility with the previous version
               if (arguments.subscriptions.size() == 1) {
                   List<String> defaultSubscriptions = Lists.newArrayList();
                   for (int i = 0; i < arguments.numSubscriptions; i++) {
                       defaultSubscriptions.add(String.format("%s-%d", arguments.subscriberName, i));
                   }
                   arguments.subscriptions = defaultSubscriptions;
               } else {
                   System.out.println("The size of subscriptions list should be equal to --num-consumers when subscriptionType isn't Exclusive");
                   jc.usage();
                   PerfClientUtils.exit(-1);
               }
           }
   And this logic causes the IndexOutOfBoundsException behind, as follows:
   
   >             // class: org.apache.pulsar.testclient.PerformanceConsumer, line: 368-374
               for (int j = 0; j < arguments.numSubscriptions; j++) {
                   String subscriberName = arguments.subscriptions.get(j);
                   for (int k = 0; k < arguments.numConsumers; k++) {
                       futures.add(consumerBuilder.clone().topic(topicName.toString()).subscriptionName(subscriberName)
                               .subscribeAsync());
                   }
               }
   Therefore, we only need to modify the judgment logic of `--subscriptions size` and `--num-subscriptions` to solve this problem, as follows:
   ![image](https://user-images.githubusercontent.com/13013780/130921837-4e7c73f2-d258-49f0-bd41-da9cfba0fcf1.png)
   @codelipenghui @eolivelli 


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar] eolivelli closed issue #11775: [testclient] --subscriptions size is less than --num-subscriptions can cause IndexOutOfBoundsException in consumption

Posted by GitBox <gi...@apache.org>.
eolivelli closed issue #11775:
URL: https://github.com/apache/pulsar/issues/11775


   


-- 
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: commits-unsubscribe@pulsar.apache.org

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