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

   Fixes https://github.com/apache/pulsar-client-go/issues/1376
   
   ### Motivation
   
   https://github.com/apache/pulsar/pull/23062 introduces a possible deadlock. 
`transactionExecutorProvider` is actually used by two different places:
   - `TopicTransactionBuffer`
   - `PendingAckHandleImpl`
   
   
https://github.com/apache/pulsar/blob/e0d7faa087f7ae6895f139b89ef333c8211f71d3/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentSubscription.java#L244
   
   
https://github.com/apache/pulsar/blob/e0d7faa087f7ae6895f139b89ef333c8211f71d3/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/pendingack/impl/PendingAckHandleImpl.java#L175
   
   The future of `PendingAckHandleImpl` is completed in this executor, while 
the executor might be executing the blocking snapshot replay task. When there 
is only 1 thread in `transactionExecutorProvider`, the reader requires the 
dispatcher for messages, while the `PendingAckHandleImpl` object cannot 
complete its future because the `transaction-executor` thread is occupied.
   
   There is another bug that when the reader fails with a non-retriable error, 
it will still exist in the cache at least for 60 seconds. See 
https://github.com/apache/pulsar/blob/e0d7faa087f7ae6895f139b89ef333c8211f71d3/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TableView.java#L45
   
   ### Modifications
   
   Reduce `numTransactionReplayThreadPoolSize` and 
`managedLedgerNumSchedulerThreads` to 1. After that, `TransactionTest` will 
always fail at `testCreateTransactionSystemTopic` when creating a consumer
   
   There are two major fixes:
   1. Add a separated executor service for the blocking snapshot replay task.
   2. Record the exception when the consumer's state becomes `Fail` and fail 
the `getLastMessageId` RPC immediately after that. In `TableView#readLatest`, 
remove the reader from cache if `readToLatest` fail.
   
   With the 1st fix, `testCreateTransactionSystemTopic` will succeed but 
`TransactionTest` will still fail in `testDeleteNamespace`. It's because the 
previous `testCreateTransactionSystemTopic` recreated the `tnx/ns1` namespace 
but the reader will keep reconnecting with `Fail` state to get the last message 
id. The 2nd fix will fix it.
   
   ### 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