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/06/21 10:05:50 UTC

[GitHub] [pulsar] Jason918 opened a new pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   <!--
   ### 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)**
   -->
   
   Related to #9173
   Master Issue: #9173
   
   ### Motivation
   
   Please see #9173
   
   ### Modifications
   
   When the BrokerService is about to create a persistent topic it checks if it is a partition of an existing partitioned topic and if so, even the auto-creation is disabled, it creates it.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   An integration test is added assuring the new behavior.
   
   ### 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
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


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

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



[GitHub] [pulsar] Jason918 commented on pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   @codelipenghui @jiazhai Hi, can you please 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.

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



[GitHub] [pulsar] codelipenghui commented on pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   Sorry Jason, after discussed, the correct way to resolve this issue is waiting for creating partitions when create the partitioned topic and users should enabled the topic auto-creation if they want to delete the inactive topic automatically. So I will close the PR first and both the issue https://github.com/apache/pulsar/issues/9173 first.
   
   Feel free to reopen it if needed.
   
   Thank.


-- 
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] gaoran10 commented on a change in pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -863,8 +863,19 @@ public void unloadNamespaceBundlesGracefully() {
             }
             final boolean isPersistentTopic = TopicName.get(topic).getDomain().equals(TopicDomain.persistent);
             if (isPersistentTopic) {
-                return topics.computeIfAbsent(topic, (topicName) -> {
-                    return this.loadOrCreatePersistentTopic(topicName, createIfMissing);
+                return topics.computeIfAbsent(topic, (name) -> {
+                    final TopicName topicName = TopicName.get(name);
+                    if (!createIfMissing && topicName.isPartitioned()) {
+                        final TopicName partitionedTopicName = TopicName.get(topicName.getPartitionedTopicName());
+                        return this.fetchPartitionedTopicMetadataAsync(partitionedTopicName).thenCompose((metadata) -> {
+                            if (topicName.getPartitionIndex() < metadata.partitions) {

Review comment:
       The `topicName.getPartitionIndex()` shouldn't be greater or equals with `metadata.partitions`, maybe this case should be rejected, we could throw an exception directly.




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

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



[GitHub] [pulsar] Anonymitaet commented on pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   Hi @Jason918 thanks for your contribution. For this PR, do we need to update docs?


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

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



[GitHub] [pulsar] Anonymitaet commented on pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   Hi @Jason918 thanks for your contribution. For this PR, do we need to update docs?


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

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



[GitHub] [pulsar] gaoran10 commented on a change in pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -863,8 +863,19 @@ public void unloadNamespaceBundlesGracefully() {
             }
             final boolean isPersistentTopic = TopicName.get(topic).getDomain().equals(TopicDomain.persistent);
             if (isPersistentTopic) {
-                return topics.computeIfAbsent(topic, (topicName) -> {
-                    return this.loadOrCreatePersistentTopic(topicName, createIfMissing);
+                return topics.computeIfAbsent(topic, (name) -> {
+                    final TopicName topicName = TopicName.get(name);
+                    if (!createIfMissing && topicName.isPartitioned()) {
+                        final TopicName partitionedTopicName = TopicName.get(topicName.getPartitionedTopicName());
+                        return this.fetchPartitionedTopicMetadataAsync(partitionedTopicName).thenCompose((metadata) -> {
+                            if (topicName.getPartitionIndex() < metadata.partitions) {

Review comment:
       The `topicName.getPartitionIndex()` shouldn't be greater or equals with `metadata.partitions`, maybe this case should be rejected, we could throw an exception directly.




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

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



[GitHub] [pulsar] Jason918 commented on pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   @codelipenghui @jiazhai Hi, can you please 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.

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



[GitHub] [pulsar] codelipenghui closed pull request #10999: [Issue 9173] [Persistent Topics] Auto-create partitions even when the auto-creation is disabled

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


   


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