poorbarcode commented on code in PR #22577:
URL: https://github.com/apache/pulsar/pull/22577#discussion_r1578990646


##########
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:
   @Demogorgon314 
   
   Separate a channel to discuss this, to make reading the context easier.
   
   > I think we intentionally overlooked the result of creating a topic for the 
remote cluster.
   > This PR may break the user's behavior of creating topic.
   > According to your description, when using the default broker 
configuration, and the geo-replication is enabled on the namespace level, the 
remote cluster will create two non-partitioned topics, 
tenant/namespace/topic-partition-1 and tenant/namespace/topic-partition-2 by 
the geo producer. Is it right?
   > If right, I would suggest adding a topic check before starting the 
replicator to make sure that the topic is the same between local and remote 
clusters, if they are the same, start the replicator, otherwise throw a log. 
You can also add this check in the replicator task.
   
   #### Answer
   
   > According to your description, when using the default broker 
configuration, and the geo-replication is enabled on the namespace level, the 
remote cluster will create two non-partitioned topics, 
tenant/namespace/topic-partition-1 and tenant/namespace/topic-partition-2 by 
the geo producer. Is it right?
   
   No, regarding this test case, the messages that were sent to `partition-1` 
will never be copied to the remote cluster because `partition-1` can not be 
created successfully.
   
   > I think we intentionally overlooked the result of creating a topic for the 
remote cluster.
   > This PR may break the user's behavior of creating topic.
   
   Without this fix, the broker eats the error, and users assume all things are 
fine. It is not correct.



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

Reply via email to