You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/04 09:37:54 UTC

[GitHub] [shardingsphere] RaigorJiang opened a new pull request #13463: Improve error message for SQLException.

RaigorJiang opened a new pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463


   Fixes #13462
   
   Changes proposed in this pull request:
   - If the next exception is not null and `getMessage()` returns blank String, get the detail message from next exception.
   
   ## Before:
   ```sql
   mysql> INSERT INTO t_order values(1,1,'ok');
   Query OK, 1 row affected (0.19 sec)
    
   mysql> INSERT INTO t_order values(2,2,'disabled');
   Query OK, 1 row affected (0.01 sec)
    
   mysql> commit;
   1815 - Internal error: 
   ```
   
   ## After:
   ```sql
   mysql> INSERT INTO t_order values(1,1,'ok');
   Query OK, 1 row affected (0.18 sec)
    
   mysql> INSERT INTO t_order values(2,2,'disabled');
   Query OK, 1 row affected (0.01 sec)
    
   mysql> commit;
   1815 - Internal error: Communications link failure during commit(). Transaction resolution unknown.
   ```
   
   ![image](https://user-images.githubusercontent.com/5668787/140291088-364942f9-3406-4197-b6e1-f4c41ead8c71.png)
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463#discussion_r742679804



##########
File path: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
##########
@@ -125,4 +126,11 @@ public static MySQLErrPacket newInstance(final Exception cause) {
         }
         return new MySQLErrPacket(1, CommonErrorCode.UNKNOWN_EXCEPTION, cause.getMessage());
     }
+    
+    private static String getErrorMessage(final SQLException cause) {
+        if (null != cause.getNextException() && StringUtils.isBlank(cause.getMessage())) {
+            return cause.getNextException().getMessage();

Review comment:
       This does not need to be the tail of the link, just get a meaningful exception for user. 
   According to all the code of `setNextException`, it makes sense to start from the first next.




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] TeslaCN commented on a change in pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463#discussion_r742676192



##########
File path: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
##########
@@ -125,4 +126,11 @@ public static MySQLErrPacket newInstance(final Exception cause) {
         }
         return new MySQLErrPacket(1, CommonErrorCode.UNKNOWN_EXCEPTION, cause.getMessage());
     }
+    
+    private static String getErrorMessage(final SQLException cause) {
+        if (null != cause.getNextException() && StringUtils.isBlank(cause.getMessage())) {
+            return cause.getNextException().getMessage();

Review comment:
       What if the next is not the tail of the link?




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463#issuecomment-960607682


   @TeslaCN  Thank you!


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] TeslaCN commented on a change in pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463#discussion_r742677653



##########
File path: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
##########
@@ -125,4 +126,11 @@ public static MySQLErrPacket newInstance(final Exception cause) {
         }
         return new MySQLErrPacket(1, CommonErrorCode.UNKNOWN_EXCEPTION, cause.getMessage());
     }
+    
+    private static String getErrorMessage(final SQLException cause) {
+        if (null != cause.getNextException() && StringUtils.isBlank(cause.getMessage())) {
+            return cause.getNextException().getMessage();

Review comment:
       Could we consider aggregating all messages in the exception link?




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on a change in pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on a change in pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463#discussion_r742683042



##########
File path: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
##########
@@ -125,4 +126,11 @@ public static MySQLErrPacket newInstance(final Exception cause) {
         }
         return new MySQLErrPacket(1, CommonErrorCode.UNKNOWN_EXCEPTION, cause.getMessage());
     }
+    
+    private static String getErrorMessage(final SQLException cause) {
+        if (null != cause.getNextException() && StringUtils.isBlank(cause.getMessage())) {
+            return cause.getNextException().getMessage();

Review comment:
       The number of connections used by the transaction is unknown, if this messages are aggregated, the result may be difficult to read.




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] TeslaCN merged pull request #13463: Improve error message for SQLException.

Posted by GitBox <gi...@apache.org>.
TeslaCN merged pull request #13463:
URL: https://github.com/apache/shardingsphere/pull/13463


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org