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

   ### Motivation
   
   During the rolling restarts, the namespace bundle ownerships will change. 
Assuming there is a producer created on a single topic, and the ownership was 
transferred to the new broker. Assuming the namespace bundle has N topics and 
the namespace is `tenant/ns`,
   1. All N topics in the same bundle of that topic will be loaded.
   2. For each topic, the managed ledger will be initialized, when the 
transaction coordinator is enabled, a `TopicTransactionBuffer` will be created. 
2.1 A Pulsar producer will be created on 
`tenant/ns/__transaction_buffer_snapshot` concurrently. 2.2 A Pulsar reader 
will be created on `tenant/ns/__transaction_buffer_snapshot` concurrently.
   3. Once all N readers are created, the owner of the snapshot topic will 
start dispatching messages to N readers. Each dispatcher will read messages 
from BookKeeper concurrently and might fail with too many requests error 
because BK can only have `maxPendingReadRequestsPerThread` pending read 
requests (default: 10000).
   
   We have a `numTransactionReplayThreadPoolSize` config to limit the 
concurrency of transaction snapshot readers. However, it only limits the read 
loop. For example, if it's configured with 1, only 1 reader could read messages 
at the same time. However, N readers will be created concurrently. Each when 
one of these reader explicitly calls `readNext`, all N dispatchers at brokers 
side will dispatch messages to N readers.
   
   The behaviors above brings much CPU pressure on the owner broker, especially 
for a small cluster with only two brokers.
   
   ### Modifications
   
   - Synchronize the reader creation, read loop and the following process on 
its result.
   - Delay the snapshot producer creaton to when a message is written via 
`LazySnapshotWriter`.
   
   ### 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