BewareMyPower commented on PR #23983: URL: https://github.com/apache/pulsar/pull/23983#issuecomment-2658160727
> @merlimat The thread switching was added in PR https://github.com/apache/pulsar/pull/9039, already in December 2020. @merlimat @lhotari to correct it, this is the very early behavior introduced in https://github.com/apache/pulsar/pull/1521. This PR intends to decouple `ManagedLedger#asyncAddEntry` and `PersistentTopic#asyncAddEntry` so that the managed ledger interface can be more flexible for the downstream protocol handlers to use. After that, all write operations from Pulsar client will still keep the original behavior that switches to managed ledger's executor to call `ManagedLedger#asyncAddEntry`. However, regarding the downstream, for example, in my Kafka protocol handler implementation, `PersistentTopic#publishMessage` is not called in an I/O thread. Instead, it's called in an independent worker thread. Then I can choose to call `persistentTopic.getManagedLedger().asyncAddEntry(/* ... */)` in order, which can be achieved by adding the `synchronized` keyword or using the same worker thread for the same topic. The comment [here](https://github.com/apache/pulsar/pull/23983#pullrequestreview-2615729014) makes sense to a certain extent, but it might be a new topic (e.g. thread switching vs. synchronized) to discuss, which is beyond the scope of this PR. -- 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]
