[improve][broker] Use full bundle name for namespace bundle destination affinity in ModularLoadManagerImpl#25518
Merged
merlimat merged 3 commits intoapache:masterfrom Apr 22, 2026
Conversation
…le names in load manager
Contributor
There was a problem hiding this comment.
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#getLeastLoadedto consume affinity using the fullServiceUnitIdstring (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
approved these changes
Apr 14, 2026
merlimat
approved these changes
Apr 14, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When unloading a namespace bundle with
destinationBrokerunderModularLoadManagerImpl, the affinity key was stored bybundleRangeonly.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 mayconsume the affinity for the wrong bundle.
As a result,
unload --destinationBrokermay appear ineffective or unstable when transferring multiple bundles that share the same range.Modifications
bundleRange.ModularLoadManagerWrapper#getLeastLoadedby full bundle name as well.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes