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/22 03:41:48 UTC

[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

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