codelipenghui commented on code in PR #21545:
URL: https://github.com/apache/pulsar/pull/21545#discussion_r1386626857
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java:
##########
@@ -56,6 +56,7 @@
import java.util.function.Supplier;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.implementation.bytecode.Throw;
Review Comment:
Not required?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1075,10 +1075,23 @@ public CompletableFuture<Optional<Topic>>
getTopic(final TopicName topicName, bo
return
loadOrCreatePersistentTopic(tpName, createIfMissing,
properties, topicPolicies);
}
- return
CompletableFuture.completedFuture(Optional.empty());
+ final String errorMsg =
+ String.format("Creating a
topic encountered an illegal partition name."
+ + "
topic_name=%s metadata_partition_number=%s",
+ topicName,
metadata.partitions);
Review Comment:
```suggestion
String.format("Illegal topic
partition name %s with max allowed %d partitions",
topicName,
metadata.partitions);
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1075,10 +1075,23 @@ public CompletableFuture<Optional<Topic>>
getTopic(final TopicName topicName, bo
return
loadOrCreatePersistentTopic(tpName, createIfMissing,
properties, topicPolicies);
}
- return
CompletableFuture.completedFuture(Optional.empty());
+ final String errorMsg =
+ String.format("Creating a
topic encountered an illegal partition name."
+ + "
topic_name=%s metadata_partition_number=%s",
+ topicName,
metadata.partitions);
+ log.warn(errorMsg);
+ return FutureUtil
+ .failedFuture(new
BrokerServiceException.NotAllowedException(errorMsg));
});
}
return loadOrCreatePersistentTopic(tpName,
createIfMissing, properties, topicPolicies);
+ }).thenCompose(optionalTopic -> {
+ if (!optionalTopic.isPresent() && createIfMissing) {
+ log.warn("Different topic automatic creation
strategies lead to race conditions. "
+ + "Try again to try to recover.
topic_name={}", topicName);
Review Comment:
```suggestion
log.warn("[{}] Try to recreate the topic with
createIfMissing=true but the returned topic is empty", topicName);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]