mattisonchao opened a new pull request, #17483:
URL: https://github.com/apache/pulsar/pull/17483

   ### Motivation
   
   See error stack trace:
   
   ```java
   [Unreachable] char[1024] “2022-08-31T08:05:02,202+0000 
[BookKeeperClientWorker-OrderedExecutor-0-0] ERROR 
org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl - Unknown exception for 
ManagedLedgerException.
   java.lang.ArrayIndexOutOfBoundsException: -22012
        at java.util.ArrayList.elementData(ArrayList.java:424) ~[?:1.8.0_322]
        at java.util.ArrayList.get(ArrayList.java:437) ~[?:1.8.0_322]
        at 
org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumers.sendMessagesToConsumers(PersistentStickyKeyDispatcherMultipleConsumers.java:256)
        at 
org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers.readEntriesComplete(PersistentDispatcherMultipleConsumers.java:517)
        at 
org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$12.readEntryComplete(ManagedCursorImpl.java:1392)
        at org.apache.bookkeeper.mledger.impl.EntryCacheImpl.”
   ```
   Relative code:
   
   
https://github.com/apache/pulsar/blob/cfe95ddacc16bd28cf076a7374dff06012f9d21d/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java#L237-L262
   
   When `unackedMessages` is greater than `maxUnackedMessages`, because 
`messagesForC` is a negative number, `ArrayIndexOutOfBoundsException` will be 
thrown on line 254. Then the exception will cause the message not to be 
delivered.
   
   ### Modifications
   
   - Add check to avoid negative results
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### Documentation
   
   - [x] `doc-not-needed` 
   (Please explain why)


-- 
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]

Reply via email to