-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker] Close protocol handlers before unloading namespace bundles #22728
Merged
Technoboy-
merged 2 commits into
apache:master
from
BewareMyPower:bewaremypower/lb-zk-thread-exception
May 21, 2024
Merged
[improve][broker] Close protocol handlers before unloading namespace bundles #22728
Technoboy-
merged 2 commits into
apache:master
from
BewareMyPower:bewaremypower/lb-zk-thread-exception
May 21, 2024
Conversation
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
…bundles ### Motivation When the extensible load manager is configured, `NamespaceService#unloadNamespaceBundle` could be stuck until 30 seconds timeout. ``` 20:19:13.746 [main:org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl@962] INFO org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl - localhost:52138 is waiting for owner for serviceUnit:public/__kafka/0xf0000000_0xffffffff 20:19:13.751 [ForkJoinPool.commonPool-worker-3:org.apache.pulsar.broker.resources.MetadataStoreCacheLoader@68] INFO org.apache.pulsar.broker.resources.MetadataStoreCacheLoader - Successfully updated broker info [] 20:19:13.751 [metadata-store-229-1:org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl@447] ERROR org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl - There is no channel owner now. 20:19:13.751 [pulsar-load-manager-222-1:org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl@459] ERROR org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl - Failed to get the channel owner. java.util.concurrent.ExecutionException: java.lang.IllegalStateException: There is no channel owner now. 20:19:43.750 [CompletableFutureDelayScheduler:org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl@953] WARN org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateChannelImpl - localhost:52138 failed to wait for owner for serviceUnit:public/__kafka/0xf0000000_0xffffffff; Trying to return the current owner:Optional[localhost:52138] ``` This case happens when there are lookup requests from Pulsar clients, `Assigning` and `Owned` events will be sent to the service unit channel. However, during the close of the last broker, the state should be `Free`. If there are active producers or consumers in the protocol handler, the state will be changed from `Free` to `Owned` and then `getActiveOwnerAsync` will be called by `getOwnerAsync`. Since no more `Owned` events will be written to the channel, the pending request in `getOwnerRequests` would never be removed. ### Modifications Close protocol handlers before unloading namespace bundles to ensure no more lookup requests were sent before the namespaces are unloaded. Add `PulsarClientBasedHandlerTest` to verify this change works.
BewareMyPower
added
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
area/broker
labels
May 17, 2024
BewareMyPower
requested review from
lhotari,
Technoboy-,
codelipenghui,
RobertIndie,
Demogorgon314 and
heesung-sn
May 17, 2024 02:42
lhotari
approved these changes
May 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lhotari
reviewed
May 17, 2024
Demogorgon314
approved these changes
May 20, 2024
Coselding
approved these changes
May 20, 2024
heesung-sn
approved these changes
May 21, 2024
Technoboy-
approved these changes
May 21, 2024
Technoboy-
pushed a commit
that referenced
this pull request
May 30, 2024
Technoboy-
pushed a commit
that referenced
this pull request
Jun 6, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/broker
cherry-picked/branch-3.2
cherry-picked/branch-3.3
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/3.2.4
release/3.3.1
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
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 the extensible load manager is configured,
NamespaceService#unloadNamespaceBundle
could be stuck until 30 seconds timeout.This case happens when there are lookup requests from Pulsar clients,
Assigning
andOwned
events will be sent to the service unit channel. However, during the close of the last broker, the state should beFree
. If there are active producers or consumers in the protocol handler, the state will be changed fromFree
toOwned
and thengetActiveOwnerAsync
will be called bygetOwnerAsync
. Since no moreOwned
events will be written to the channel, the pending request ingetOwnerRequests
would never be removed.Modifications
Close protocol handlers before unloading namespace bundles to ensure no more lookup requests were sent before the namespaces are unloaded.
Add
PulsarClientBasedHandlerTest
to verify this change works.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: