-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix][cpp] Support retry and apply operation timeout for lookup reque…
…sts (#17410) ### Motivation Currently the operation timeout only works for requests other than lookup, like SEND and FLOW. However, the lookup requests, which are sent by `LookupService`, should also apply the operation timeout, see https://github.com/apache/pulsar/blob/7075a5ce0d4a70f52625ac8c3d0c48894442b72a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java#L1019-L1025 In addition, no attempts would be retried if lookup failed even due to a retryable reason. For example, if some of all configured brokers were down, the C++ client would fail immediately. Therefore, this PR intends to retry lookup for some certain cases: - The connection cannot be established, except connection timeout, which is controlled by the connection timeout. - A `ServiceNotReady` error is received, except it's caused by `PulsarServerException`, e.g. the listener name is wrong. Then, apply the operation timeout to avoid infinite retries. ### Modifications - Add a `ResultRetryable` error code, which should only be used internally. Complete the futures with this error in the cases said previously. - Add a `RetryableLookupService` implementation to support retries based on the backoff policy. Replace the directly usages of `LookupService` implementations with this class in `ClientImpl`. The following tests are added: - `ClientTest.testMultiBrokerUrl`: verify when multiple brokers are configured, even if one of them is not available, the creation of producer or consumer could still succeed. - `LookupService.testRetry`: verify all lookup methods could be retried. - `LookupService.testTimeout`: verify all lookup methods could be completed with `ResultTimeout` if no brokers are available. ### TODO In future, we should add lookup timeout instead of operation timeout for lookup requests and separate lookup connection pool, see PIP-91. * Handle ResultRetryable in handleDisconnection (cherry picked from commit 86ea31b)
- Loading branch information
1 parent
d0fcade
commit 590d91f
Showing
15 changed files
with
348 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.