Visitar URL original
[fix][client] Apply V5 connection backoff initial and max intervals by kalayciburak · Pull Request #26799 · apache/pulsar · GitHub
Skip to content

[fix][client] Apply V5 connection backoff initial and max intervals - #26799

Merged
lhotari merged 1 commit into
apache:masterfrom
kalayciburak:fix/v5-connection-backoff
Oct 1, 2026
Merged

lhotari merged 1 commit into
apache:masterfrom
kalayciburak:fix/v5-connection-backoff

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Fixes #26788

Motivation

ConnectionPolicy.connectionBackoff is documented as the reconnection strategy, but PulsarClientBuilderV5.connectionPolicy copied every other connection field and skipped the backoff. Producers, consumers and the other connection handlers therefore reconnected with the v4 defaults (100 ms initial, 60 s max), whatever the application configured.

The v4 client already exposes those two delays as initialBackoffIntervalNanos and maxBackoffIntervalNanos. It always doubles the delay and uses a 10% jitter, so a custom multiplier or jitter still has no counterpart and must not be dropped silently.

Modifications

  • Apply BackoffPolicy.initialInterval() and maxInterval() to the v4 client configuration.
  • Reject a policy whose multiplier is not 2 or whose jitter is not the default, instead of ignoring it.
  • Document that contract on PulsarClientBuilder.connectionPolicy.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • connectionBackoffInitialAndMaxAreApplied failed on current master with expected [5000000000] but found [100000000] (5 s configured, 100 ms default kept), then passed after the fix.
  • connectionBackoffRejectsMultiplierAndJitterTheClientCannotApply failed before the rejection (expected IllegalArgumentException), then passed.
  • ./gradlew :pulsar-client-v5:test --tests org.apache.pulsar.client.impl.v5.PulsarClientBuilderV5Test -PtestRetryCount=0 — 33 tests, 0 failures.
  • :pulsar-client-v5:checkstyleMain, :pulsar-client-v5:checkstyleTest, :pulsar-client-api-v5:checkstyleMain, and spotless Java checks for those modules passed.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Public API: PulsarClient.builder().connectionPolicy(...) now applies a supported reconnection backoff. A BackoffPolicy with a non-default multiplier (including fixed) or a non-default jitter is rejected with IllegalArgumentException. The default policy (exponential(100 ms, 60 s), multiplier 2, 10% jitter) still matches the previous defaults.

ConnectionPolicy.connectionBackoff was copied into every other connection
field and then dropped, so reconnection kept the v4 defaults. Apply the
initial and max intervals, and reject a multiplier or jitter the v4 client
cannot represent instead of ignoring them.

Fixes apache#26788

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMd

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check that the initialInterval and maxInterval match the v4 defaults

@kalayciburak

Copy link
Copy Markdown
Contributor Author

checked, they already match. ConnectionPolicy.builder() defaults to exponential(100ms, 60s), same as ClientConfigurationData (100ms / 60s) and the v4 Backoff defaults (100ms / 1min). applying the default policy doesn't change those values.

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for checking!

@lhotari
lhotari merged commit 7cf7321 into apache:master Oct 1, 2026
44 checks passed
@lhotari lhotari added this to the 5.0.0 milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][client] V5 ConnectionPolicy.connectionBackoff is ignored

2 participants