You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/01/27 13:14:27 UTC

[GitHub] [pulsar] hangc0276 commented on issue #13431: We can still get topic’s schema When deleting both the topic&schema

hangc0276 commented on issue #13431:
URL: https://github.com/apache/pulsar/issues/13431#issuecomment-1023193455


   @yuruguo Partitioned and non-partitioned topic has the same problem. We can provide the `deleteSchema` method to support the schema deletion no matter the topic load or not.
   ```java
    public CompletableFuture<SchemaVersion> deleteSchema(String topicName) {
           String base = TopicName.get(topicName).getPartitionedTopicName();
           String id = TopicName.get(base).getSchemaName();
           SchemaRegistryService schemaRegistryService = pulsar.getSchemaRegistryService();
           return BookkeeperSchemaStorage.ignoreUnrecoverableBKException(schemaRegistryService.getSchema(id))
               .thenCompose(schema -> {
                   if (schema != null) {
                       // It's different from `SchemasResource.deleteSchema`
                       // because when we delete a topic, the schema
                       // history is meaningless. But when we delete a schema of a topic, a new schema could be
                       // registered in the future.
                       log.info("Delete schema storage of id: {}", id);
                       return schemaRegistryService.deleteSchemaStorage(id);
                   } else {
                       return CompletableFuture.completedFuture(null);
                   }
               });
       }
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org