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

   ### Motivation
   
   https://github.com/apache/pulsar/pull/23940 brings a behavior change that 
the core logic of `ManagedLedger#asyncAddEntry` now won't switch threads, which 
means it will be executed directly in Netty I/O thread via 
`PersistentTopic#asyncAddEntry`.
   
   The `beforeAddEntry` method calls the`intercept` and 
`interceptWithNumberOfMessages` methods for **all broker entry interceptors** 
and prepends a new broker entry metadata buffer on the original buffer (though 
it's just a composite buffer).
   
   There is a risk that when many producers send messages to the same managed 
ledger concurrently, the process of `asyncAddEntry` might block the Netty I/O 
thread for some time and cause the performance regression.
   
   ### Modifications
   
   In `PersistentTopic#publishMessage`, expose the `getExecutor()` method for 
`ManagedLedger` and execute `ManagedLedger#asyncAddEntry` in that executor. The 
change of https://github.com/apache/pulsar/pull/12606 is moved to 
`PersistentTopic` as well that the buffer is retained before switching to 
another thread. After that, only synchronize `afterAddEntryToQueue` with other 
synchronized methods of `ManagedLedgerImpl`.
   
   `ManagedLedgerImpl#asyncAddEntry` still doesn't switch the thread, so it 
would still be possible for the downstream application to synchronize 
`asyncAddEntry`, either by adding a lock (e.g. `synchronized`) or executing 
this method is a single thread.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions 
will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since 
the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed 
in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments 
have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


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