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

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

commit 18cf75b8f3828c7bfdf32aaa320ec7d12d8d5226
Author: Zike Yang <[email protected]>
AuthorDate: Fri Feb 7 09:48:47 2025 +0800

    [improve][broker] Avoid printing log for IncompatibleSchemaException 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
    
    (cherry picked from commit 3c0bbee91368086189816c26357491e4fe596e01)
---
 .../src/main/java/org/apache/pulsar/broker/service/ServerCnx.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
index 27e0b0469b9..234f4e2973f 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
@@ -1615,8 +1615,12 @@ public class ServerCnx extends PulsarHandler implements 
TransportCnx {
                                     
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;
                     });

Reply via email to