You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "heesung-sn (via GitHub)" <gi...@apache.org> on 2024/07/22 22:39:08 UTC

[PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

heesung-sn opened a new pull request, #23064:
URL: https://github.com/apache/pulsar/pull/23064

   
   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*. 
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   -->
   
   
   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/pip/README.md -->
   
   ### Motivation
   
   <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
   
   - Found a bug that the ownership monitor tries to clean owned bundles from inactive source brokers
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   
   - Fix the bug not to clean owned bundles from inactive source brokers
   - Cleaned/refactored override ownership code
   - Skip unloading LB internal topics. Instead, close those topics when shutting down the broker.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *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
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on code in PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#discussion_r1688435826


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java:
##########
@@ -993,5 +997,26 @@ public void disableBroker() throws Exception {
         serviceUnitStateChannel.cleanOwnerships();
         leaderElectionService.close();
         brokerRegistry.unregister();
+        // Close the internal topics (if owned any) after giving up the possible leader role,
+        // so that the subsequent lookups could hit the next leader.
+        closeInternalTopics();
+    }
+
+    private void closeInternalTopics() {
+        List<CompletableFuture<Void>> futures = new ArrayList<>();
+        for (String name : INTERNAL_TOPICS) {
+            futures.add(pulsar.getBrokerService().getTopicIfExists(name)
+                    .thenAccept(topicOptional -> topicOptional.ifPresent(topic -> topic.close(true)))
+                    .exceptionally(__ -> {
+                        log.warn("Failed to close internal topic:{}", name);
+                        return null;
+                    }));
+        }
+        try {
+            FutureUtil.waitForAll(futures)
+                    .get(pulsar.getConfiguration().getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS);

Review Comment:
   It's not clear to me that the metadata store timeout is the most relevant choice here. What about `namespaceBundleUnloadingTimeoutMs` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#issuecomment-2245774979

   Should this not be cherry-picked to 3.1 too?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#issuecomment-2245786747

   > Should this not be cherry-picked to 3.1 too?
   Sure. I can push it there too.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#issuecomment-2243928899

   @heesung-sn Please add the following content to your PR description and select a checkbox:
   ```
   - [ ] `doc` <!-- Your PR contains doc changes -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn merged PR #23064:
URL: https://github.com/apache/pulsar/pull/23064


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#discussion_r1688439130


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java:
##########
@@ -993,5 +997,26 @@ public void disableBroker() throws Exception {
         serviceUnitStateChannel.cleanOwnerships();
         leaderElectionService.close();
         brokerRegistry.unregister();
+        // Close the internal topics (if owned any) after giving up the possible leader role,
+        // so that the subsequent lookups could hit the next leader.
+        closeInternalTopics();
+    }
+
+    private void closeInternalTopics() {
+        List<CompletableFuture<Void>> futures = new ArrayList<>();
+        for (String name : INTERNAL_TOPICS) {
+            futures.add(pulsar.getBrokerService().getTopicIfExists(name)
+                    .thenAccept(topicOptional -> topicOptional.ifPresent(topic -> topic.close(true)))
+                    .exceptionally(__ -> {
+                        log.warn("Failed to close internal topic:{}", name);
+                        return null;
+                    }));
+        }
+        try {
+            FutureUtil.waitForAll(futures)
+                    .get(pulsar.getConfiguration().getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS);

Review Comment:
   good point. will update it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#discussion_r1690153125


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -2250,6 +2250,15 @@ private CompletableFuture<Integer> unloadServiceUnit(NamespaceBundle serviceUnit
         topics.forEach((name, topicFuture) -> {
             TopicName topicName = TopicName.get(name);
             if (serviceUnit.includes(topicName)) {
+                if (ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(pulsar)
+                        && ExtensibleLoadManagerImpl.isInternalTopic(topicName.toString())) {
+                    if (log.isDebugEnabled()) {

Review Comment:
   Agreed. I think it is better to put this log under `ExtensibleLoadManagerImpl.debug ` too.  Updated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #23064:
URL: https://github.com/apache/pulsar/pull/23064#discussion_r1689368480


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -2250,6 +2250,15 @@ private CompletableFuture<Integer> unloadServiceUnit(NamespaceBundle serviceUnit
         topics.forEach((name, topicFuture) -> {
             TopicName topicName = TopicName.get(name);
             if (serviceUnit.includes(topicName)) {
+                if (ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(pulsar)
+                        && ExtensibleLoadManagerImpl.isInternalTopic(topicName.toString())) {
+                    if (log.isDebugEnabled()) {

Review Comment:
   Should we use `ExtensibleLoadManagerImpl.debug` here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only) [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn closed pull request #23064: [fix][broker] Do not try to clean owned bundles from inactive source brokers (ExtensibleLoadManagerImpl only)
URL: https://github.com/apache/pulsar/pull/23064


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org