sijie commented on a change in pull request #4731: Add deleted schema judgment when adding schema URL: https://github.com/apache/pulsar/pull/4731#discussion_r303715828
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java ########## @@ -129,7 +145,10 @@ .setTimestamp(clock.millis()) .addAllProps(toPairs(schema.getProps())) .build(); - return schemaStorage.put(schemaId, info.toByteArray(), context); + + return getMaxDeletedVersion(schemaId).thenCompose(deleteVersion -> Review comment: I think we should return the maxDeletedVersion when we are doing compatibility check above. This would reduce the number of times we are reading schema info. So the logic would be something like this: ``` getSchema(schemaId).thenCompose(existingSchema -> { if (existingSchema == null) { return completedFuture(-1L, true) } else if (existingSchema.schema.isDeleted()) { return completedFuture(existingSchema.schema.version, true); } else { if (isTransitiveStrategy) { return ...; } else { // find the maxDeletedVersion in backward sequence. return ...; } } }).thenCompose((maxDeletedVersion, isCompatible) -> { }) ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services