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/02/12 23:41:59 UTC

[PR] [improve][broker] Set the serviceUnitStateChannel topic compaction threshold explicitly [pulsar]

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

   
   
   <!--
   ### 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
   
   We better set the compaction threshold of the serviceUnitStateChannel topic when initializing itself instead of relying on other components' init.
   
   ### Modifications
   
   - Set the compaction threshold of the serviceUnitStateChannel topic when initializing itself
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### 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 -->
   - [x] `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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,14 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            if (config.isSystemTopicAndTopicLevelPoliciesEnabled()) {

Review Comment:
   What happens if this flag returns false? Is that a valid way to configure Pulsar with this code? would it make sense to prevent such configuration in the first place, or at least log a warning?
   



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,12 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            Long threshold = pulsar.getAdminClient().topicPolicies().getCompactionThreshold(TOPIC);
+            if (threshold == null || COMPACTION_THRESHOLD != threshold) {
+                pulsar.getAdminClient().topicPolicies().setCompactionThreshold(TOPIC, COMPACTION_THRESHOLD);
+                log.info("Set compaction threshold for system topic {}.", TOPIC);
+            }

Review Comment:
   I think currently topic policy is required to set this compaction threshold. 
   
    pulsar.getAdminClient().topics().setCompcationThreshold(..) has been deprecated by https://github.com/apache/pulsar/pull/7881/files



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -984,6 +984,9 @@ public void conflictAndCompactionTest() throws ExecutionException, InterruptedEx
         channel3.close();
         FieldUtils.writeDeclaredField(channel2,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
+        admin.topicPolicies()
+                .setCompactionThreshold(ServiceUnitStateChannelImpl.TOPIC, threshold);

Review Comment:
   I think this should always pass. I wonder in what cases this `setCompactionThreshold ` might fail?



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,12 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            Long threshold = pulsar.getAdminClient().topicPolicies().getCompactionThreshold(TOPIC);
+            if (threshold == null || COMPACTION_THRESHOLD != threshold) {
+                pulsar.getAdminClient().topicPolicies().setCompactionThreshold(TOPIC, COMPACTION_THRESHOLD);
+                log.info("Set compaction threshold for system topic {}.", TOPIC);
+            }

Review Comment:
   Is there a way to override this only if there's no topic-level policy already? Otherwise, this might make it harder to debug/workaround issues in the future.



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,12 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            Long threshold = pulsar.getAdminClient().topicPolicies().getCompactionThreshold(TOPIC);
+            if (threshold == null || COMPACTION_THRESHOLD != threshold) {
+                pulsar.getAdminClient().topicPolicies().setCompactionThreshold(TOPIC, COMPACTION_THRESHOLD);
+                log.info("Set compaction threshold for system topic {}.", TOPIC);
+            }

Review Comment:
   I meant, isn't it possible that a topic-level policy has already been set, and we'd be overriding that?



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,12 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            Long threshold = pulsar.getAdminClient().topicPolicies().getCompactionThreshold(TOPIC);
+            if (threshold == null || COMPACTION_THRESHOLD != threshold) {
+                pulsar.getAdminClient().topicPolicies().setCompactionThreshold(TOPIC, COMPACTION_THRESHOLD);
+                log.info("Set compaction threshold for system topic {}.", TOPIC);
+            }

Review Comment:
   We can check if (!config().isSystemTopicAndTopicLevelPoliciesEnabled()) to make sure the topic policy has been enabled or not. Nice catch!



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -984,6 +984,9 @@ public void conflictAndCompactionTest() throws ExecutionException, InterruptedEx
         channel3.close();
         FieldUtils.writeDeclaredField(channel2,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
+        admin.topicPolicies()
+                .setCompactionThreshold(ServiceUnitStateChannelImpl.TOPIC, threshold);

Review Comment:
   I'm sorry for the confusion. It's not that `setCompactionThreshold` might fail, but anything in between the previous call to this "reset" call might (i.e., lines https://github.com/apache/pulsar/pull/22048/files#diff-0bb4e0f521ef681668abbb30387c7de6ebf6cfce7dcbdd3d2f318ac50f6cc8abR967-R986). So put the entire respective block in a `try` and this in a `finally`.



-- 
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] Set the ServiceUnitStateChannel topic compaction threshold explicitly and other bug fixes [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn closed pull request #22048: [fix][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly and other bug fixes
URL: https://github.com/apache/pulsar/pull/22048


-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -984,6 +984,9 @@ public void conflictAndCompactionTest() throws ExecutionException, InterruptedEx
         channel3.close();
         FieldUtils.writeDeclaredField(channel2,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
+        admin.topicPolicies()
+                .setCompactionThreshold(ServiceUnitStateChannelImpl.TOPIC, threshold);

Review Comment:
   Can we put this in a `finally` block to limit the blast radius of this test if it fails?



-- 
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] [improve][broker] Set the ServiceUnitStateChannel topic compaction threshold explicitly [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -298,6 +299,12 @@ public synchronized void start() throws PulsarServerException {
 
             ExtensibleLoadManagerImpl.createSystemTopic(pulsar, TOPIC);
 
+            Long threshold = pulsar.getAdminClient().topicPolicies().getCompactionThreshold(TOPIC);
+            if (threshold == null || COMPACTION_THRESHOLD != threshold) {
+                pulsar.getAdminClient().topicPolicies().setCompactionThreshold(TOPIC, COMPACTION_THRESHOLD);
+                log.info("Set compaction threshold for system topic {}.", TOPIC);
+            }

Review Comment:
   We can check if (config().isSystemTopicAndTopicLevelPoliciesEnabled()) to make sure the topic policy has been enabled or not. Nice catch!



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -984,6 +984,9 @@ public void conflictAndCompactionTest() throws ExecutionException, InterruptedEx
         channel3.close();
         FieldUtils.writeDeclaredField(channel2,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
+        admin.topicPolicies()
+                .setCompactionThreshold(ServiceUnitStateChannelImpl.TOPIC, threshold);

Review Comment:
   oh I see. nice catch. 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