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 2021/02/09 12:47:37 UTC

[GitHub] [pulsar] BewareMyPower opened a new pull request #9544: [C++] Add detail logs for schema related messages

BewareMyPower opened a new pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544


   ### Motivation
   
   If broker failed to parse the schema, the logs of C++/Python client is poor because when C++ client handles the `Error` response, it doesn't print the `message` field that is filled by broker. On the other hand, if the `InvalidSchemaDataException` is thrown by `StructSchemaDataValidator#throwInvalidSchemaDataException`, the detail error message will be written to the exception's cause. The String that `getMessage()` returns is not enough
   
   ### Modifications
   
   - When `tryAddSchema` failed, add the exception cause's message to the error message that's sent to client.
   - Print `Error` response's `message` field to logs.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is a trivial rework / code cleanup without any test coverage. Take #9483 (which is to be fixed) as the example, before this PR, the client side's log is like
   
   ```
   Received error response from server: IncompatibleSchema -- req_id: 0
   ```
   
   After this PR, the client side's log will be
   
   ```
   Received error response from server: IncompatibleSchema (Invalid schema definition data for AVRO schema caused by org.apache.avro.SchemaParseException: Undefined name: "array") -- req_id: 0
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#issuecomment-776068269


   /pulsarbot run-failure-checks


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#issuecomment-776545242


   /pulsarbot run-failure-checks


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] sijie merged pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
sijie merged pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#issuecomment-776827981


   /pulsarbot run-failure-checks


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#issuecomment-776908626


   /pulsarbot run-failure-checks


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on a change in pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on a change in pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#discussion_r573418245



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1167,9 +1167,13 @@ protected void handleProducer(final CommandProducer cmdProducer) {
                             CompletableFuture<SchemaVersion> schemaVersionFuture = tryAddSchema(topic, schema);
 
                             schemaVersionFuture.exceptionally(exception -> {
+                                String message = exception.getMessage();
+                                if (exception.getCause() != null) {
+                                    message += (" caused by " + exception.getCause().toString());

Review comment:
       Fixed




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#discussion_r573194221



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1167,9 +1167,13 @@ protected void handleProducer(final CommandProducer cmdProducer) {
                             CompletableFuture<SchemaVersion> schemaVersionFuture = tryAddSchema(topic, schema);
 
                             schemaVersionFuture.exceptionally(exception -> {
+                                String message = exception.getMessage();
+                                if (exception.getCause() != null) {
+                                    message += (" caused by " + exception.getCause().toString());

Review comment:
       ```suggestion
                                       message += (" caused by " + exception.getCause());
   ```
   
   You don't need to use `toString` here. It is problematic as `exception.getCause` can return `null`.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -1727,7 +1731,11 @@ protected void handleGetOrCreateSchema(CommandGetOrCreateSchema commandGetOrCrea
                 CompletableFuture<SchemaVersion> schemaVersionFuture = tryAddSchema(topic, schema);
                 schemaVersionFuture.exceptionally(ex -> {
                     ServerError errorCode = BrokerServiceException.getClientErrorCode(ex);
-                    commandSender.sendGetOrCreateSchemaErrorResponse(requestId, errorCode, ex.getMessage());
+                    String message = ex.getMessage();
+                    if (ex.getCause() != null) {
+                        message += (" caused by " + ex.getCause().toString());

Review comment:
       ```suggestion
                           message += (" caused by " + ex.getCause());
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on pull request #9544: [C++] Add detail logs for schema related messages

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #9544:
URL: https://github.com/apache/pulsar/pull/9544#issuecomment-776159677


   /pulsarbot run-failure-checks


----------------------------------------------------------------
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:
users@infra.apache.org