liangyepianzhou commented on PR #17449:
URL: https://github.com/apache/pulsar/pull/17449#issuecomment-1298425453

   The problem is not caused by the check of the AUTO_CONSUME.
   It is that there are some `activeConsumer` with AUTO_CONSUME.
   And then the new consumer with the new other schemas will fail at 
`addSchemaIfIdleOrCheckCompatible` with the exception 
`IncompatibleSchemaException("Topic does not have schema to check").
   `
   IMO, The check is confusing. If there is no hasSchema, then we should 
`addSchema` without other conditions.
   
https://github.com/apache/pulsar/blob/fe1963988fc6883f52826069a781b91aba0405bf/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L3037
   >   if (hasSchema
                           || (!producers.isEmpty())
                           || (numActiveConsumers != 0)
                           || (ledger.getTotalSize() != 0)) {
                       return checkSchemaCompatibleForConsumer(schema);
                   } else {
                       return addSchema(schema).thenCompose(schemaVersion ->
                               CompletableFuture.completedFuture(null));
                   }
   
    Why did not we change it to 
    >    if (hasSchema) {
                       return checkSchemaCompatibleForConsumer(schema);
                   } else {
                       return addSchema(schema).thenCompose(schemaVersion ->
                               CompletableFuture.completedFuture(null));
                   }          
        
   And store the schema of the byte[]
   >    if (si != null && (SchemaType.BYTES == si.getType() || SchemaType.NONE 
== si.getType())) {
               // don't set schema for Schema.BYTES
               si = null;
           }
   
   change it to 
   >   if (si != null && SchemaType.NONE == si.getType()) {
               // don't set schema for Schema.BYTES
               si = 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to