michaeljmarshall commented on code in PR #19153:
URL: https://github.com/apache/pulsar/pull/19153#discussion_r1087471562
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1033,17 +1047,33 @@ public CompletableFuture<Optional<Topic>>
getTopic(final TopicName topicName, bo
});
} else {
return topics.computeIfAbsent(topicName.toString(), (name) -> {
+ topicEventsDispatcher.notify(topicName.toString(),
TopicEvent.LOAD, EventStage.BEFORE);
if (topicName.isPartitioned()) {
final TopicName partitionedTopicName =
TopicName.get(topicName.getPartitionedTopicName());
return
this.fetchPartitionedTopicMetadataAsync(partitionedTopicName).thenCompose((metadata)
-> {
if (topicName.getPartitionIndex() <
metadata.partitions) {
- return createNonPersistentTopic(name);
+ topicEventsDispatcher
+ .notify(topicName.toString(),
TopicEvent.CREATE, EventStage.BEFORE);
+
+ CompletableFuture<Optional<Topic>> res =
createNonPersistentTopic(name);
+
+ topicEventsDispatcher.notifyOnCompletion(res,
topicName.toString(), TopicEvent.CREATE);
+ topicEventsDispatcher.notifyOnCompletion(res,
topicName.toString(), TopicEvent.LOAD);
Review Comment:
Actually, the `testEventsPersistentPartitionedTopic()` passes because the
order is correct because the `loadFuture` is added as a callback to the
`topicFuture` before the `CREATE` callback is added.
In the case of this code that I highlighted, test
`testEventsNonPersistentNonPartitionedTopic()` appears to be passing because
`res` is already completed. (That test actually runs on 1072 and 1073, but the
result is the same.)
I haven't looked closely, but that may be a result of using an in memory
metadata store, which is actually synchronous.
Ultimately, both non-partitioned and partitioned topics will have issues
related to futures and unknown completion status. I think it might be best to
document that the order is not guaranteed since it shouldn't really impact
user's designs.
--
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]