Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][client] add maxRetryRequestTimes in ClientConfigurationData and remove Duplicate retry logic #23989

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

walkinggo
Copy link
Contributor

Motivation

The maxRetries property of AsyncHttpConnector is derived from the config of DefaultAsyncHttpClient.

@SneakyThrows
    public AsyncHttpConnector(int connectTimeoutMs, int readTimeoutMs,
                              int requestTimeoutMs,
                              int autoCertRefreshTimeSeconds, ClientConfigurationData conf,
                              boolean acceptGzipCompression) {
        Validate.notEmpty(conf.getServiceUrl(), "Service URL is not provided");
        serviceNameResolver = new PulsarServiceNameResolver();
        String serviceUrl = conf.getServiceUrl();
        serviceNameResolver.updateServiceUrl(serviceUrl);
        this.acceptGzipCompression = acceptGzipCompression;
        AsyncHttpClientConfig asyncHttpClientConfig =
                createAsyncHttpClientConfig(conf, connectTimeoutMs, readTimeoutMs, requestTimeoutMs,
                        autoCertRefreshTimeSeconds);
        httpClient = createAsyncHttpClient(asyncHttpClientConfig);
        this.requestTimeout = requestTimeoutMs > 0 ? Duration.ofMillis(requestTimeoutMs) : null;
        this.maxRetries = httpClient.getConfig().getMaxRequestRetry();
    }

This causes both DefaultAsyncHttpClient and AsyncHttpConnector to share the same retry count value. However, since both components implement their own retry logic, this configuration actually results in accumulated retries exceeding the configured limit. Given that DefaultAsyncHttpClient has a default retry count of 5, I propose disabling retries in DefaultAsyncHttpClient (setting its retry count to 0) while maintaining the default configuration, to centralize retry handling exclusively within AsyncHttpConnector.

Modifications

  1. Retry Configuration Support
    Added maxRetryRequestTimes in ClientConfigurationData (default: 5) to control admin client request retry behavior. Configuration propagates to AsyncHttpConnector implementations.

  2. Client API Enhancements

  • Extended ClientBuilder interface with new maxRetryTimes() method
  • Implemented configuration injection in ClientBuilderImpl
  1. HTTP Connector Refactoring
  • Modified AsyncHttpConnector to use centralized configuration instead of AsyncHttpClient's internal retry setting
  • Explicitly disabled underlying library retry via confBuilder.setMaxRequestRetry(0)
  1. Validation
    Added parameter verification test in ClientBuilderImplTest to validate retry time configuration constraint

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: walkinggo#9

…Impl。AsyncHttpConnector use maxRetry from ClientConfigurationData
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 15, 2025
@thetumbled
Copy link
Member

thetumbled commented Feb 17, 2025

Changes related to configuration modification need a pip.

@walkinggo
Copy link
Contributor Author

Changes related to configuration modification need a pip.

Apologies, this PR was created in response to an existing TODO comment. I'll promptly draft a PIP document and submit it to the community mailing list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants