strongduanmu opened a new issue, #23653:
URL: https://github.com/apache/shardingsphere/issues/23653

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   
[d74a714](https://github.com/apache/shardingsphere/commit/d74a71433a51f4be25b508091d5f0925ab48885b)
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-JDBC
   
   ### Expected behavior
   
   Init druid datasource and connection successfully.
   
   ### Actual behavior
   
   ```
   2023-1-19 17:50:04[TID: N/A][ INFO](DruidDataSource.java:994) {dataSource-1} 
inited
   2023-1-19 17:50:04[TID: N/A][ WARN](:) DataSource health check failed
   org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain 
JDBC Connection; nested exception is java.sql.SQLException: Connection is closed
           at 
org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
 ~[spring-jdbc-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           at 
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:324) 
~[spring-jdbc-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           at 
org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator.getProduct(DataSourceHealthIndicator.java:124)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator.doDataSourceHealthCheck(DataSourceHealthIndicator.java:107)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator.doHealthCheck(DataSourceHealthIndicator.java:102)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthIndicator.getHealth(HealthIndicator.java:37)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:80)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpoint.getHealth(HealthEndpoint.java:38)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:106)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpointSupport.getAggregateHealth(HealthEndpointSupport.java:116)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpointSupport.getContribution(HealthEndpointSupport.java:103)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:81)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpointSupport.getHealth(HealthEndpointSupport.java:68)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:74)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:65)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_301]
           at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_301]
           at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_301]
           at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_301]
           at 
org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:279) 
~[spring-core-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           at 
org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:77)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96)
 ~[spring-boot-actuator-2.2.0.RELEASE.jar:2.2.0.RELEASE]
           at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
 ~[?:1.8.0_301]
           at 
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) 
~[?:1.8.0_301]
           at 
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
 ~[?:1.8.0_301]
           at 
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
 ~[?:1.8.0_301]
           at 
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
 ~[?:1.8.0_301]
           at 
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
 ~[?:1.8.0_301]
           at 
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
 ~[?:1.8.0_301]
           at sun.reflect.GeneratedMethodAccessor275.invoke(Unknown Source) 
~[?:?]
           at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_301]
           at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_301]
           at 
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) 
~[?:1.8.0_301]
           at sun.rmi.transport.Transport$1.run(Transport.java:200) 
~[?:1.8.0_301]
           at sun.rmi.transport.Transport$1.run(Transport.java:197) 
~[?:1.8.0_301]
           at java.security.AccessController.doPrivileged(Native Method) 
~[?:1.8.0_301]
           at sun.rmi.transport.Transport.serviceCall(Transport.java:196) 
~[?:1.8.0_301]
           at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) 
~[?:1.8.0_301]
           at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
 ~[?:1.8.0_301]
           at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
 ~[?:1.8.0_301]
           at java.security.AccessController.doPrivileged(Native Method) 
~[?:1.8.0_301]
           at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) 
~[?:1.8.0_301]
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
~[?:1.8.0_301]
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
~[?:1.8.0_301]
           at java.lang.Thread.run(Thread.java:748) [?:1.8.0_301]
   Caused by: java.sql.SQLException: Connection is closed
           at 
com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection.lambda$getClosedConnection$0(ProxyConnection.java:494)
 ~[HikariCP-3.4.1.jar:?]
           at com.sun.proxy.$Proxy231.getTransactionIsolation(Unknown Source) 
~[?:?]
           at 
com.zaxxer.hikari.pool.HikariProxyConnection.getTransactionIsolation(HikariProxyConnection.java)
 ~[HikariCP-3.4.1.jar:?]
           at 
org.apache.shardingsphere.driver.jdbc.core.connection.ConnectionManager.getTransactionIsolation(ConnectionManager.java:235)
 ~[shardingsphere-jdbc-core-1.2.0.20221212.jar:1.2.0.20221212]
           at 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.getTransactionIsolation(ShardingSphereConnection.java:233)
 ~[shardingsphere-jdbc-core-1.2.0.20221212.jar:1.2.0.20221212]
           at 
com.alibaba.druid.filter.FilterChainImpl.connection_getTransactionIsolation(FilterChainImpl.java:419)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.filter.FilterAdapter.connection_getTransactionIsolation(FilterAdapter.java:873)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.filter.FilterChainImpl.connection_getTransactionIsolation(FilterChainImpl.java:415)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.getTransactionIsolation(ConnectionProxyImpl.java:259)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidConnectionHolder.<init>(DruidConnectionHolder.java:142)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidConnectionHolder.<init>(DruidConnectionHolder.java:79)
 ~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:924) 
~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1383) 
~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1379) 
~[druid-1.1.22.jar:1.1.22]
           at 
com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:109) 
~[druid-1.1.22.jar:1.1.22]
           at 
org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
 ~[spring-jdbc-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           at 
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
 ~[spring-jdbc-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           at 
org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
 ~[spring-jdbc-5.2.0.RELEASE.jar:5.2.0.RELEASE]
           ... 47 more
   2023-1-19 17:50:04[TID: N/A][ INFO](:)  [DUBBO] Notify urls for subscribe 
url 
provider://192.168.2.100:20880/com.watsons.rts.rpc.stub.EventMsgPublicService?anyhost=true&application=watsons-rts-provider-service&bind.ip=192.168.2.100&bind.port=20880&category=configurators&check=false&deprecated=false&dispatcher=all&dubbo=2.0.2&dynamic=true&generic=false&interface=com.watsons.rts.rpc.stub
   ```
   
   ### Reason analyze (If you can)
   
   Druid will close statement and resultset after validate connection with 
`SELECT 1`.
   
   
![image](https://user-images.githubusercontent.com/10829171/213419875-93af5368-c12e-4ef0-a328-94bb739a4fd4.png)
   
   At this time, the close method of ShardingSphere AbstractStatementAdapter 
will be called, and the TrafficExecutor#close method will be called internally, 
which closes the connection by mistake.
   
   
![image](https://user-images.githubusercontent.com/10829171/213420132-c6ea4a1c-61c4-4482-a600-d9a120aea623.png)
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   ### 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]

Reply via email to