BewareMyPower opened a new pull request, #15049: URL: https://github.com/apache/pulsar/pull/15049
### Motivation #13023 introduced a performance regression, see details in https://github.com/apache/pulsar/pull/13023#issuecomment-1090045572. It might be caused by the frequent thread switch. Because to ensure the message order, we must execute `ConsumerBase#triggerListener` in a single thread because it will deliver the received message to other threads, see https://github.com/apache/pulsar/blob/81da8d3cd199fd6c1e4510a1c1c2ac71418efd5e/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java#L970-L977 However, it's necessary for the correctness because `triggerListener` could be called in two places: - `messageReceived`, which is called in `pulsar-io-xxx` thread. - `callMessageListener`, which is called in `pulsar-external-listener-xxx` thread. Then these two threads can retrieve the results concurrently and it leads to the message disordering. This PR is to add a test that verifies the message order when message listener is configured so that the following PRs won't introduce the regression to correctness. ### Modifications - Add `SimpleProducerConsumerTest#testListenerOrdering`. - Make `triggerListener` private and the derived classes of `ConsumerBase` must call `tryTriggerListener`. It makes the code more clear that the performance issue is related to `triggerListener`. ### Verifying this change If we removed the `internalPinnedExecutor.execute` block in `triggerListener`, the `testListenerOrdering` could fail easily. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
