[branch-2.10][cherry-pick] Fix the broker close hanged issue. #17689
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.
Cherry-pick #15755
Master issue #15643, #15753
Motivation
Blocked at BrokerService#unloadNamespaceBundlesGracefully:
Blocked at CoordinationServiceImpl#close
For BrokerService#unloadNamespaceBundlesGracefully, the request chain :
For CoordinationServiceImpl#close, the request chain :
We find that it's all related to ResourceLock#release.
As the CI using the MockedZooKeeper, I find that if there are some RuntimeException, the response could never finish. So I add the catch block to ensure that all the requests will reply. But I'm not sure if the return code is right.
pulsar/testmocks/src/main/java/org/apache/zookeeper/MockZooKeeper.java
Lines 332 to 402 in 3a80458
pulsar/testmocks/src/main/java/org/apache/zookeeper/MockZooKeeper.java
Lines 916 to 976 in 3a80458
More, the current close process has some order issues. LoadManager is closed before BrokerService, but BrokerService closes need to invoke LoadManager, even though the LoadManager is stateless, but is a little confused here.
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Lines 443 to 452 in 3a80458
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Lines 891 to 902 in 3a80458
Documentation
no-need-doc
(Please explain why)