This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 483a6db  Fix the schema deletion when delete topic with delete schema 
(#11501)
483a6db is described below

commit 483a6dba7a96a00139ad400866f6b6c807356a98
Author: lipenghui <[email protected]>
AuthorDate: Fri Jul 30 11:26:55 2021 +0800

    Fix the schema deletion when delete topic with delete schema (#11501)
    
    The delete topic REST API already provided delete schema option,
    but the delete topic command does not apply this option,
    instead call the delete schema independently.
    
    And the delete schema REST API has a different behavior with the delete 
topic
    REST API with deleteSchema=true. When delete a topic with delete schema 
option,
    the schema ledgers and schema indexes will be deleted, but delete schema 
independently
    only write a delete marker to the schema storage.
    
    We may need to improve the delete schema API, but the improvement does not 
in this PR.
    This PR just correct the delete topic with delete schema behavior.
    
    (cherry picked from commit cc54f704f5e1c8618b2afa75e3d6e9006a459e36)
---
 .../java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java  | 10 ++++------
 .../src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java   | 10 ++--------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git 
a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
 
b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
index 0f4a424..9bba43f 100644
--- 
a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
+++ 
b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
@@ -693,9 +693,8 @@ public class PulsarAdminToolTest {
 
         CmdTopics cmdTopics = new CmdTopics(admin);
 
-        cmdTopics.run(split("delete persistent://myprop/clust/ns1/ds1 -d"));
-        verify(mockTopics).delete("persistent://myprop/clust/ns1/ds1", false);
-        verify(mockSchemas).deleteSchema("persistent://myprop/clust/ns1/ds1");
+        cmdTopics.run(split("delete persistent://myprop/clust/ns1/ds1 -f -d"));
+        verify(mockTopics).delete("persistent://myprop/clust/ns1/ds1", true, 
true);
 
         cmdTopics.run(split("unload persistent://myprop/clust/ns1/ds1"));
         verify(mockTopics).unload("persistent://myprop/clust/ns1/ds1");
@@ -756,9 +755,8 @@ public class PulsarAdminToolTest {
         cmdTopics.run(split("get-partitioned-topic-metadata 
persistent://myprop/clust/ns1/ds1"));
         
verify(mockTopics).getPartitionedTopicMetadata("persistent://myprop/clust/ns1/ds1");
 
-        cmdTopics.run(split("delete-partitioned-topic 
persistent://myprop/clust/ns1/ds1 -d"));
-        
verify(mockTopics).deletePartitionedTopic("persistent://myprop/clust/ns1/ds1", 
false);
-        verify(mockSchemas, 
times(2)).deleteSchema("persistent://myprop/clust/ns1/ds1");
+        cmdTopics.run(split("delete-partitioned-topic 
persistent://myprop/clust/ns1/ds1 -d -f"));
+        
verify(mockTopics).deletePartitionedTopic("persistent://myprop/clust/ns1/ds1", 
true, true);
 
         cmdTopics.run(split("peek-messages persistent://myprop/clust/ns1/ds1 
-s sub1 -n 3"));
         verify(mockTopics).peekMessages("persistent://myprop/clust/ns1/ds1", 
"sub1", 3);
diff --git 
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java 
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
index dbc9ff2..059fe1e 100644
--- 
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
+++ 
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
@@ -443,10 +443,7 @@ public class CmdTopics extends CmdBase {
         @Override
         void run() throws Exception {
             String topic = validateTopicName(params);
-            topics.deletePartitionedTopic(topic, force);
-            if (deleteSchema) {
-                admin.schemas().deleteSchema(topic);
-            }
+            topics.deletePartitionedTopic(topic, force, deleteSchema);
         }
     }
 
@@ -467,10 +464,7 @@ public class CmdTopics extends CmdBase {
         @Override
         void run() throws PulsarAdminException {
             String topic = validateTopicName(params);
-            topics.delete(topic, force);
-            if (deleteSchema) {
-                admin.schemas().deleteSchema(topic);
-            }
+            topics.delete(topic, force, deleteSchema);
         }
     }
 

Reply via email to