simply-lu opened a new issue #8415:
URL: https://github.com/apache/shardingsphere/issues/8415
Hello, we use sharding-jdbc-spring-boot-starter, a single database query
takes a long time, and during the stress test, the database connection timeout
occurs after about 30 threads.
sharding-jdbc-spring-boot-starter version: 4.0.0 4.0.1 4.1.0 4.1.1
Database connection pool: hikari or druid
Database version: mysql 5.7
Database middleware: mybatis-plus
Language: java
Configuration file:
spring:
shardingsphere:
datasource:
names: master,slave0,slave1
master:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
host: 10.254.64.x
port: 3306
db: user_db
url:
jdbc:mysql://${spring.shardingsphere.datasource.master.host}:${spring.shardingsphere.datasource.master.port}/${spring.shardingsphere.datasource.master.db}?characterEncoding=utf8&zeroDateTimeBehavior
=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
slave0:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
host: 10.254.64.x
port: 3306
db: user_db
url:
jdbc:mysql://${spring.shardingsphere.datasource.slave0.host}:${spring.shardingsphere.datasource.slave0.port}/${spring.shardingsphere.datasource.slave0.db}?characterEncoding=utf8&zeroDateTimeBehavior
=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
slave1:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
host: 10.254.64.x
port: 3306
db: user_db
url:
jdbc:mysql://${spring.shardingsphere.datasource.slave1.host}:${spring.shardingsphere.datasource.slave1.port}/${spring.shardingsphere.datasource.slave1.db}?characterEncoding=utf8&zeroDateTimeBehavior
=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
masterslave:
master-data-source-name: master
slave-data-source-names: slave0,slave1
name: ms
load-balance-algorithm-type: round_robin
props:
sql:
show: true
Error message:
2020-11-26 10:41:30.142 ERROR 8 --- [ XNIO-1 task-30]
c.a.h.f.b.u.c.v2.UserController : 登录异常
org.springframework.dao.TransientDataAccessResourceException:
### Error querying database. Cause:
java.sql.SQLTransientConnectionException: HikariPool-2 - Connection is not
available, request timed out after 30000ms.
### The error may exist in class path resource [mapper/UserMapper.xml]
### The error may involve
com.asr.hedu.fsp.biz.user.mapper.UserMapper.selectUserByPhone
### The error occurred while executing a query
### SQL: select id as userId, `status`, password from
tb_user where del_flag = 0 and phone = ? and role = ?
### Cause: java.sql.SQLTransientConnectionException: HikariPool-2 -
Connection is not available, request timed out after 30000ms.
; HikariPool-2 - Connection is not available, request timed out after
30000ms.; nested exception is java.sql.SQLTransientConnectionException:
HikariPool-2 - Connection is not available, request timed out after 30000ms.
at
org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:70)
~[spring-jdbc-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
~[spring-jdbc-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
~[spring-jdbc-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
~[mybatis-spring-2.0.0.jar!/:2.0.0]
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
~[mybatis-spring-2.0.0.jar!/:2.0.0]
at com.sun.proxy.$Proxy157.selectOne(Unknown Source) ~[na:na]
at
org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
~[mybatis-spring-2.0.0.jar!/:2.0.0]
at
com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:99)
~[mybatis-plus-core-3.1.0.jar!/:3.1.0]
at
com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:61)
~[mybatis-plus-core-3.1.0.jar!/:3.1.0]
at com.sun.proxy.$Proxy187.selectUserByPhone(Unknown Source) ~[na:na]
at
com.asr.hedu.fsp.biz.user.service.impl.UserServiceImpl.selectUserByPhone(UserServiceImpl.java:391)
~[classes!/:2.1.0-SNAPSHOT]
at
com.asr.hedu.fsp.biz.user.service.impl.UserServiceImpl$$FastClassBySpringCGLIB$$166f232d.invoke(<generated>)
~[classes!/:2.1.0-SNAPSHOT]
at
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
[spring-core-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685)
~[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
com.asr.hedu.fsp.biz.user.service.impl.UserServiceImpl$$EnhancerBySpringCGLIB$$13a4263.selectUserByPhone(<generated>)
~[classes!/:2.1.0-SNAPSHOT]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController.login$original$U4gZbVDY(UserController.java:176)
[classes!/:2.1.0-SNAPSHOT]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController.login$original$U4gZbVDY$accessor$rysivHtv(UserController.java)
[classes!/:2.1.0-SNAPSHOT]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController$auxiliary$gbV9G3wA.call(Unknown
Source) [classes!/:2.1.0-SNAPSHOT]
at
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:93)
[skywalking-agent.jar:6.3.0]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController.login(UserController.java)
[classes!/:2.1.0-SNAPSHOT]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController$$FastClassBySpringCGLIB$$25e0b59f.invoke(<generated>)
[classes!/:2.1.0-SNAPSHOT]
at
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
[spring-core-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)
[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:120)
[spring-context-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
~[spring-tx-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
~[spring-tx-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
~[spring-aop-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at
com.asr.hedu.fsp.biz.user.controller.v2.UserController$$EnhancerBySpringCGLIB$$4d5d10f9.login(<generated>)
~[classes!/:2.1.0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_111]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_111]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_111]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
----------------------------------------------------------------
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:
[email protected]