poorbarcode commented on code in PR #22577:
URL: https://github.com/apache/pulsar/pull/22577#discussion_r1579059969
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorTest.java:
##########
@@ -652,4 +652,63 @@ public void testUnFenceTopicToReuse() throws Exception {
admin2.topics().delete(topicName);
});
}
+
+ @Test
+ public void testNamespaceLevelReplicationRemoteConflictTopicExist() throws
Exception {
+ final String topicName = BrokerTestUtil.newUniqueName("persistent://"
+ replicatedNamespace + "/tp");
+ // Verify: will get a not found error when calling
"getPartitionedTopicMetadata" on a topic not exists.
+ try {
+ admin1.topics().getPartitionedTopicMetadata(topicName);
+ fail("Expected a not found error");
+ } catch (Exception ex) {
+ Throwable unWrapEx = FutureUtil.unwrapCompletionException(ex);
+ assertTrue(unWrapEx.getMessage().contains("not found"));
+ }
+ // Verify: will get a conflict error when there is a topic with
different partitions on the remote side.
+ admin2.topics().createPartitionedTopic(topicName, 1);
+ try {
+ admin1.topics().createPartitionedTopic(topicName, 2);
Review Comment:
> If the remote cluster's topic equals the topic that will be created, how
to handle it?
Broker assumes created successfully when the topic is the same as trying to
create. See
https://github.com/apache/pulsar/pull/22577/files#diff-6902810fd24ff29ec34052bcc6a0de36d76107649148d945b80ec2be888e9042R683-R686
```java
if (topicMeta.partitions == numPartitions) {
log.info("[{}] Skip created partitioned topic {} in cluster {}, because
that {}",
clientAppId(), topicName, cluster, unwrapEx2.getMessage());
createRemoteTopicFuture.complete(null);
}
```
> How to roll back a remote cluster's topic if the remote cluster's topic
created the cluster successfully, but the local cluster's creation failed.
Before creating topics at the remote cluster, the check for creating topics
at the local cluster has been passed, so it is less probably to fail. Users
should handle the error manually if created on the local cluster failed, for
example, they can try again.
--
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]