Technoboy- opened a new pull request #14614: URL: https://github.com/apache/pulsar/pull/14614
Cherry-pick https://github.com/apache/pulsar/pull/14433 Fixes #14413 ### Motivation When Retry topics are enabled, ConsumerBuilderImpl performs a backwards-compatibility check to look for DLQ or Retry topics that were created on previous version of Pulsar using a different naming scheme. It does this by calling `getPartitionedTopicMetadata` and then using `.get()` to block while waiting for the results ```java if (client.getPartitionedTopicMetadata(oldRetryLetterTopic) .get(client.conf.getOperationTimeoutMs(), TimeUnit.MILLISECONDS).partitions > 0) { retryLetterTopic = oldRetryLetterTopic; } if (client.getPartitionedTopicMetadata(oldDeadLetterTopic) .get(client.conf.getOperationTimeoutMs(), TimeUnit.MILLISECONDS).partitions > 0) { deadLetterTopic = oldDeadLetterTopic; } ``` This was implemented in https://github.com/apache/pulsar/pull/10129 A partial fix to add a Timeout was implemented in https://github.com/apache/pulsar/pull/11597 However this fix does still block the calling thread during the lookup. This can be an issue for code that attempt to call `subscribeAsync` on a non-blocking Pool (such as when using Netty). The signature of `subscribeAsync` implies that it's non-blocking. (And it seems somewhat pointless to have `subscribeAsync` if it blocks anyway) Note that this is an undocumented *breaking* change in behavior. Up until 2.9, it was safe to call this from a non-blocking pool. In our case, we were running a custom SLF4J log exporter on the same thread pool, which resulted in a *deadlock* when the number of concurrent `subscribeAsync` calls exceeded the pool size. (This is probably an extreme example and a poor decision on our part, but perhaps a good example of why unexpected blocking can be dangerous) Note that blocking call is still made even if the retry and DLQ names are explicitly specified in DeadLetterPolicy. In that scenario the check should not be needed. Aside from blocking the calling Thread, this also results in unneeded lookup requests. ### Modifications - Make retry and DLQ metadata async. ### Documentation - [x] `no-need-doc` -- 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]
