lhotari commented on pull request #12456: URL: https://github.com/apache/pulsar/pull/12456#issuecomment-949488081
> Run the callback for consumer.receiveAsync() on the internalPinnedExecutor. I chose to run the whole callback on the internalPinnedExecutor instead of just the messageReceived method. If we left the callback using thenAccept and ran messageReceived on the internalPinnedExecutor, there is a chance that the callback will run on the calling thread, which is always the internalPinnedExecutor. That would mean that the messageReceived logic would actually run after the remaining callback logic that inspects the incomingMessages.size() and decides whether or not to pause the consumer. By scheduling the callback on the internalPinnedExecutor using thenAcceptAsync, we guarantee that the code is run together without the data race we're fixing in this PR. Good catch @michaeljmarshall! Yes that's true that the other consumer will be another thread and thenAcceptAsync is needed to fix another potential race. -- 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]
