Skip to content

[improve][broker] Use full bundle name for namespace bundle destination affinity in ModularLoadManagerImpl#25518

Merged
merlimat merged 3 commits intoapache:masterfrom
Demogorgon314:Demogorgon314/Enhance-broker-affinity-handling-by-using-full-bundle-names-in-load-manager
Apr 22, 2026
Merged

[improve][broker] Use full bundle name for namespace bundle destination affinity in ModularLoadManagerImpl#25518
merlimat merged 3 commits intoapache:masterfrom
Demogorgon314:Demogorgon314/Enhance-broker-affinity-handling-by-using-full-bundle-names-in-load-manager

Conversation

@Demogorgon314
Copy link
Copy Markdown
Member

Motivation

When unloading a namespace bundle with destinationBroker under ModularLoadManagerImpl, the affinity key was stored by bundleRange only.

Different namespaces can share the same bundle range, especially for single-bundle namespaces such as 0x00000000_0xffffffff. In that case, the destination affinity can collide across namespaces, and the next lookup may
consume the affinity for the wrong bundle.

As a result, unload --destinationBroker may appear ineffective or unstable when transferring multiple bundles that share the same range.

Modifications

  • Store namespace bundle destination affinity by full bundle name instead of bare bundleRange.
  • Consume the destination affinity in ModularLoadManagerWrapper#getLeastLoaded by full bundle name as well.
  • Add an admin-side test to verify the affinity key passed to the load manager is the full bundle name.
  • Add a load manager test to verify affinity lookup is resolved by full bundle name.

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes destination-broker affinity collisions during namespace bundle unloads under ModularLoadManagerImpl by keying affinity with the full bundle name (namespace + range) instead of only the bundle range, ensuring bundles from different namespaces don’t overwrite each other.

Changes:

  • Update ModularLoadManagerWrapper#getLeastLoaded to consume affinity using the full ServiceUnitId string (full bundle name).
  • Update admin unload path (NamespacesBase#setNamespaceBundleAffinityAsync) to store affinity using the resolved full bundle name.
  • Add a load manager test to ensure affinity lookup is resolved by full bundle name for bundles sharing the same range.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerWrapper.java Consume namespace bundle affinity using the full bundle name rather than extracted bundle range.
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java Store namespace bundle affinity under the full bundle name derived from (namespace, bundleRange).
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImplTest.java Add coverage to validate affinity lookup is independent across namespaces that share the same range.

@BewareMyPower BewareMyPower added release/4.0.10 release/4.2.1 type/bug The PR fixed a bug or issue reported a bug labels Apr 14, 2026
@merlimat merlimat merged commit db94b95 into apache:master Apr 22, 2026
43 checks passed
lhotari pushed a commit that referenced this pull request Apr 23, 2026
…on affinity in ModularLoadManagerImpl (#25518)

(cherry picked from commit db94b95)
lhotari pushed a commit that referenced this pull request Apr 23, 2026
…on affinity in ModularLoadManagerImpl (#25518)

(cherry picked from commit db94b95)
lhotari pushed a commit that referenced this pull request Apr 23, 2026
…on affinity in ModularLoadManagerImpl (#25518)

(cherry picked from commit db94b95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants