You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/11/16 08:54:10 UTC

[GitHub] [pulsar] Jason918 opened a new pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Jason918 opened a new pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830


   <!--
   ### Contribution Checklist
     
     - Name the pull request in the form "[Issue XYZ][component] Title of the pull request", where *XYZ* should be replaced by the actual issue number.
       Skip *Issue XYZ* if there is no associated github issue for this pull request.
       Skip *component* if you are unsure about which is the best component. E.g. `[docs] Fix typo in produce method`.
   
     - 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.
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ### Motivation
   
   Currently, , we update the value of `Topic#topicMaxMessageSize` in an interval of  `maxMessageSizeCheckIntervalInSeconds` (default as 60s). 
   So if we update this value, we will have a delay, max to 60s by default, before it take effects.
   We can reduce the latency by updating the value with notification.
   
   Further, we can avoid the blank updates in `isExceedMaximumMessageSize`.
   
   ### Modifications
   
   1. Move `topicMaxMessageSize` to HierarchyTopicPolicies , and update by `onUpdate` listener, like other topic policies.
   2. Deprecates `maxMessageSizeCheckIntervalInSeconds`, since it has no use any more.
   3. Remove `lastTopicMaxMessageSizeCheckTimeStamp` and `topicMaxMessageSizeCheckIntervalMs`, no use any more.
   4. Move method `registerTopicPolicyListener` up to AbstractTopic level, since `topicMaxMessageSize` also effect non-persist topics.
   
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - org.apache.pulsar.broker.admin.TopicPoliciesTest#testTopicMaxMessageSize, and added test case for non-persisitent topics.
     - Add org.apache.pulsar.broker.admin.TopicPoliciesTest#testTopicPolicyInitValue to cover  the case that topic loading old settings.
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
     - The rest endpoints: (no)
     - The admin cli options: (no)
     - Anything that affects deployment: (no)
   
   ### Documentation
   
   Check the box below and label this PR (if you have committer privilege).
   
   Need to update docs? 
     
   - [x] `doc` 
   
   Doc updated in comments.
   And checked with old configuration doc, no `maxMessageSizeCheckIntervalInSeconds` found, and no need to add since it is deprecated.
   
   
   


-- 
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



[GitHub] [pulsar] Jason918 commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r758957060



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyHierarchyValue.java
##########
@@ -36,6 +36,8 @@
     @Getter
     private volatile T namespaceValue;
 
+    @VisibleForTesting

Review comment:
       Removed.




-- 
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



[GitHub] [pulsar] Jason918 commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r758956943



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -1958,8 +1968,25 @@ private void doTestTopicMaxMessageSize(boolean isPartitioned) throws Exception {
         assertNull(admin.topicPolicies().getMaxMessageSize(topic));
         // set msg size
         admin.topicPolicies().setMaxMessageSize(topic, 10);
-        Awaitility.await().until(()
-                -> pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic)) != null);

Review comment:
       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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-970257911


   /pulsarbot run-failure-checks


-- 
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



[GitHub] [pulsar] codelipenghui merged pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830


   


-- 
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



[GitHub] [pulsar] Jason918 commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r757212222



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -1900,45 +1902,86 @@ public void testTopicMaxMessageSizeApi() throws Exception{
 
     @Test(timeOut = 20000)
     public void testTopicMaxMessageSize() throws Exception{
-        doTestTopicMaxMessageSize(true);
-        doTestTopicMaxMessageSize(false);
+        doTestTopicMaxMessageSize(TopicDomain.persistent,true);
+        doTestTopicMaxMessageSize(TopicDomain.persistent,false);
+        doTestTopicMaxMessageSize(TopicDomain.non_persistent,true);
+        doTestTopicMaxMessageSize(TopicDomain.non_persistent,false);

Review comment:
       DONE




-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-971356129


   /pulsarbot run-failure-checks
   


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-979675609


   > Could you please show me where update the PolicyHierarchyValue.brokerValue?
   
   Last line in method `updateTopicPolicyByBrokerConfig`


-- 
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



[GitHub] [pulsar] Jason918 removed a comment on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 removed a comment on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-971356129


   /pulsarbot run-failure-checks
   


-- 
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



[GitHub] [pulsar] codelipenghui commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r754044291



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -986,9 +986,12 @@
     )
     private int retentionCheckIntervalInSeconds = 120;
 
+    @Deprecated
     @FieldContext(
             category = CATEGORY_SERVER,
-            doc = "Check between intervals to see if max message size of topic policy has updated. default is 60s"
+            deprecated = true,
+            doc = "Check between intervals to see if  of topic policy has updated. default is 60s."
+                + "Note: This is deprecated, max message size is updated by notification."
     )
     private int maxMessageSizeCheckIntervalInSeconds = 60;

Review comment:
       I think we can remove it directly, it will not introduce any compatibility issues after users upgrade to the new version, and please also delete the config from the broker.conf and standalone.conf




-- 
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



[GitHub] [pulsar] codelipenghui commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-975562716


   Yes, but I think we should keep consistent in the local topic policy cache? And for the next step, we can apply the `PolicyHierarchyValue` to get topic policy.


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-974576332


   @codelipenghui @315157973   Please help take a look.


-- 
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



[GitHub] [pulsar] codelipenghui closed pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
codelipenghui closed pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830


   


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-975327776


   > I think you missed the `updateTopicPolicyByBrokerConfig` to apply the default broker configuration?
   
   Not really. You mean ServiceConfiguration#maxMessageSize, it take effects in the netty RPC layer.
   See https://github.com/apache/pulsar/blob/3a337b8952239136cb77302e22021b3d79154f1c/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarChannelInitializer.java#L130
   


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-975326764


   > I think you missed the `updateTopicPolicyByBrokerConfig` to apply the default broker configuration?
   
   Not really. You mean ServiceConfiguration#maxMessageSize, it take effects in the netty RPC layer.
   See https://github.com/apache/pulsar/blob/3a337b8952239136cb77302e22021b3d79154f1c/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarChannelInitializer.java#L130
   


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-975633035


   > Yes, but I think we should keep consistent in the local topic policy cache? And for the next step, we can apply the `PolicyHierarchyValue` to get topic policy.
   
   Great point. Added. And it's easier to find out which policy have broker/ns/topic level setting.


-- 
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



[GitHub] [pulsar] codelipenghui commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
codelipenghui commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r756919973



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -1900,45 +1902,86 @@ public void testTopicMaxMessageSizeApi() throws Exception{
 
     @Test(timeOut = 20000)
     public void testTopicMaxMessageSize() throws Exception{
-        doTestTopicMaxMessageSize(true);
-        doTestTopicMaxMessageSize(false);
+        doTestTopicMaxMessageSize(TopicDomain.persistent,true);
+        doTestTopicMaxMessageSize(TopicDomain.persistent,false);
+        doTestTopicMaxMessageSize(TopicDomain.non_persistent,true);
+        doTestTopicMaxMessageSize(TopicDomain.non_persistent,false);

Review comment:
       We can just define a data provider.




-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-971364389


   /pulsarbot run-failure-checks


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-976095726


   /pulsarbot run-failure-checks


-- 
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



[GitHub] [pulsar] Jason918 commented on pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#issuecomment-971100625


   /pulsarbot run-failure-checks


-- 
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



[GitHub] [pulsar] 315157973 commented on a change in pull request #12830: [broker]Optimize topicMaxMessageSize with topic local cache.

Posted by GitBox <gi...@apache.org>.
315157973 commented on a change in pull request #12830:
URL: https://github.com/apache/pulsar/pull/12830#discussion_r758938845



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyHierarchyValue.java
##########
@@ -36,6 +36,8 @@
     @Getter
     private volatile T namespaceValue;
 
+    @VisibleForTesting

Review comment:
       Now that there is a getter, why do we need VisibleForTesting?

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -1958,8 +1968,25 @@ private void doTestTopicMaxMessageSize(boolean isPartitioned) throws Exception {
         assertNull(admin.topicPolicies().getMaxMessageSize(topic));
         // set msg size
         admin.topicPolicies().setMaxMessageSize(topic, 10);
-        Awaitility.await().until(()
-                -> pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic)) != null);

Review comment:
       We should not remove this judgment. Even if it is a partitioned topic, only the topic without -partition- will be saved in the Topic Policy.
   
   For example: persistent://tenant/namespace/topic-partition has 10 partitions, only one copy of data will be saved in Topic Policy, and the key is persistent://tenant/namespace/topic-partition




-- 
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