TeslaCN commented on issue #18897:
URL: 
https://github.com/apache/shardingsphere/issues/18897#issuecomment-1193736057

   ## Description
   
   The root cause of this issue: **When handling exceptions, exceptions caused 
by data problems are not considered.**
   
   This logic is added in PR 
<https://github.com/apache/shardingsphere/pull/8760>, the original intention is 
to deal with the inconsistency of the front and back database types of 
ShardingSphere-Proxy.
   
   For example, ShardingSphere-Proxy uses the MySQL protocol to provide 
external services, and the database that Proxy actually connects to is the 
PostgreSQL database.
   
   Use MySQL Connector/J to connect to ShardingSphere-Proxy. During the 
connection establishment phase, some special SQL will be sent, such as querying 
MySQL-specific variables. If MySQL-specific SQL such as `show tables` is 
directly executed in PostgreSQL, an error will occur.
   
   The use of `getSaneResult` in the `catch (SQLException)` process is to 
handle the above situation.
   
   Why judge isTrunkThread and only getSaneResult in the main thread?
   At that time, only exceptions occurring in heterogeneous data sources were 
considered, and exceptions caused by data problems were not considered. The 
Actual SQL executed by ShardingSphere using multiple threads must originate 
from the same Logic SQL.
   
   For example, when `show tables` is executed to PostgreSQL, the results of 
multi-threaded concurrent execution must be consistent, so only the errors of 
the main thread are processed and saneResult is obtained.
   
   ## My Solution
   
   Checking Protocol Type in JDBCExecutorCallback:
   
   `getSaneResult` only if Protocol Type does not match Database Type.
   When the scenario does not involve heterogeneous data sources, the exception 
returned by the database is thrown directly.


-- 
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