dawnbreaks opened a new issue, #35269:
URL: https://github.com/apache/shardingsphere/issues/35269
## Bug Report
### Which version of ShardingSphere did you use?
5.1.2, but we modified the source code and did some customization to meet
our special business requirements.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy for MySQL DB
### Expected behavior
SQL Got executed successfully
### Actual behavior
Got an NullPointerException in the MySQL JDBC layer.
```
java.sql.SQLException: null
at
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at
com.mysql.cj.jdbc.ConnectionImpl.setDatabase(ConnectionImpl.java:2123)
at com.mysql.cj.jdbc.ConnectionImpl.setCatalog(ConnectionImpl.java:2067)
at
com.zaxxer.hikari.pool.ProxyConnection.setCatalog(ProxyConnection.java:421)
at
com.zaxxer.hikari.pool.HikariProxyConnection.setCatalog(HikariProxyConnection.java)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection.getConnections$original$xJFhhoAc(JDBCBackendConnection.java:101)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection.getConnections$original$xJFhhoAc$accessor$q01rQfmq(JDBCBackendConnection.java)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection$auxiliary$oJ4oLlgo.call(Unknown
Source)
at
org.apache.shardingsphere.agent.core.plugin.interceptor.InstanceMethodAroundInterceptor.intercept(InstanceMethodAroundInterceptor.java:85)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection.getConnections(JDBCBackendConnection.java)
at
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.group(DriverExecutionPrepareEngine.java:82)
at
org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine.prepare(AbstractExecutionPrepareEngine.java:62)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:175)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:134)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.executeSkipParse$original$0BobDpyn(ProxySQLExecutor.java:142)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.executeSkipParse$original$0BobDpyn$accessor$VDVhzzuf(ProxySQLExecutor.java)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor$auxiliary$YIlblXtX.call(Unknown
Source)
at
org.apache.shardingsphere.agent.core.plugin.interceptor.InstanceMethodAroundInterceptor.intercept(InstanceMethodAroundInterceptor.java:85)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.executeSkipParse(ProxySQLExecutor.java)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:172)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:80)
at
org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandle.execute(SchemaAssignedDatabaseBackendHandle.java:56)
at
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.AbstractQueryCommandExecutor.execute(AbstractQueryCommandExecutor.java:62)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:213)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run$original$98lrJfsb(CommandExecutorTask.java:118)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run$original$98lrJfsb$accessor$x5uFNR1v(CommandExecutorTask.java)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask$auxiliary$9fqbhwcy.call(Unknown
Source)
at
org.apache.shardingsphere.agent.core.plugin.interceptor.InstanceMethodAroundInterceptor.intercept(InstanceMethodAroundInterceptor.java:85)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException: null
at
com.mysql.cj.protocol.a.NativeProtocol.checkForOutstandingStreamingData(NativeProtocol.java:1917)
at
com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:611)
at
com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket$original$ZAAgqQWr(NativeProtocol.java:951)
at
com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket$original$ZAAgqQWr$accessor$6Jz1PMJY(NativeProtocol.java)
at
com.mysql.cj.protocol.a.NativeProtocol$auxiliary$5i3iFb2x.call(Unknown Source)
at
org.apache.shardingsphere.agent.core.plugin.interceptor.InstanceMethodInterceptorArgsOverride.intercept(InstanceMethodInterceptorArgsOverride.java:74)
at
com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java)
at
com.mysql.cj.protocol.a.NativeProtocol.sendQueryString(NativeProtocol.java:897)
at com.mysql.cj.NativeSession.execSQL(NativeSession.java:1073)
at
com.mysql.cj.jdbc.ConnectionImpl.setDatabase(ConnectionImpl.java:2119)
... 30 common frames omitted
```
### Reason analyze (If you can)
I believe that there is an concurrency issue for the JDBC connection in the
proxy server. if a SQL is too slow, an business application might be close
the TCP connection to the proxy server before receiving the response, and then
the proxy server will close the HikariProxyConnection immediately, which will
make the JDBC connection ready for access by another thread, that is to say
there will be two threads concurrently accessing the same JDBC connection, so
the Internal data of the JDBC Connection might be broken.
When an frontend connection got inactive, the proxy server should not close
the JDBC Connection immediately, please refer to this file:
https://github.com/apache/shardingsphere/blob/bb495066a45b7950d9385c08cfda82a59738973b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java#L103
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
Sorry, it is very hard to reproduce this behavior, but we it really occurred
in our production env recently.
### Example codes for reproduce this issue (such as a github 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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]