Skip to content

Commit

Permalink
[improve][broker] Avoid printing log for IncompatibleSchemaException …
Browse files Browse the repository at this point in the history
…in ServerCnx (#23938)

### Motivation

If the producer is created with some schema error, the broker will print many error logs like this:

```
ERROR org.apache.pulsar.broker.service.ServerCnx - Try add schema failed, remote address xxx
java.util.concurrent.CompletionException: org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException: Producers cannot connect or send message without a schema to topics with a schemawhen SchemaValidationEnforced is enabled
```

This error can be reported to the client and not need to print it in the broker.

### Modifications

- Avoid printing log for IncompatibleSchemaException in ServerCnx
  • Loading branch information
RobertIndie authored Feb 7, 2025
1 parent 5e5d514 commit 3c0bbee
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,12 @@ protected void handleProducer(final CommandProducer cmdProducer) {
BrokerServiceException.getClientErrorCode(exception),
message);
}
log.error("Try add schema failed, remote address {}, topic {}, producerId {}", remoteAddress,
topicName, producerId, exception);
var cause = FutureUtil.unwrapCompletionException(exception);
if (!(cause instanceof IncompatibleSchemaException)) {
log.error("Try add schema failed, remote address {}, topic {}, producerId {}",
remoteAddress,
topicName, producerId, exception);
}
producers.remove(producerId, producerFuture);
return null;
});
Expand Down

0 comments on commit 3c0bbee

Please sign in to comment.