连接tidb出错

为提高效率,提问时请尽量提供详细背景信息,问题描述清晰可优先响应。以下信息点请尽量提供: tidb版本:3.0.3 问题描述:在我运行一段时候后,再连接tidb抛出以下错误: ERROR 2019-11-06 16:59:36 com.taimeitetch.flinketl.facade.impl.ExecuteEngineFacadeImpl.process(85) | org.springframework.dao.RecoverableDataAccessException:

Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 916,696 milliseconds ago. The last packet sent successfully to the server was 916,697 milliseconds ago.

The error may exist in URL [jar:file:/data/flink_process/flinketl-process-1.0.0.jar!/com/taimeitetch/flinketl/service/base/dao/ColumnDescMapper.xml]

The error may involve com.taimeitetch.flinketl.service.base.dao.ColumnDescMapper.selectByTable-Inline

The error occurred while setting parameters

SQL: SHOW COLUMNS FROM edc.edc_subject_item_group_value

Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 916,696 milliseconds ago. The last packet sent successfully to the server was 916,697 milliseconds ago. ; SQL []; Communications link failure

The last packet successfully received from the server was 916,696 milliseconds ago. The last packet sent successfully to the server was 916,697 milliseconds ago.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 916,696 milliseconds ago. The last packet sent successfully to the server was 916,697 milliseconds ago. at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:98) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:74) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:421) at com.sun.proxy.$Proxy17.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:206) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) at com.sun.proxy.$Proxy20.selectByTable(Unknown Source) at com.taimeitetch.flinketl.service.base.impl.CommonServiceImpl.findTableStructure(CommonServiceImpl.java:152) at com.taimeitetch.flinketl.service.base.impl.CommonServiceImpl.findTableStructureMap(CommonServiceImpl.java:160) at com.taimeitetch.flinketl.service.input.impl.SelectSqlServiceImpl.fetchProcess(SelectSqlServiceImpl.java:83) at com.taimeitetch.flinketl.service.input.impl.SelectSqlServiceImpl.fetchProcess(SelectSqlServiceImpl.java:47) at com.taimeitetch.flinketl.facade.engines.process.impl.OfflineJobProcessImpl.executeByPipeline(OfflineJobProcessImpl.java:165) at com.taimeitetch.flinketl.facade.engines.process.impl.OfflineJobProcessImpl.process(OfflineJobProcessImpl.java:118) at com.taimeitetch.flinketl.facade.engines.impl.FlinkEngineImpl.executeEngin(FlinkEngineImpl.java:37) at com.taimeitetch.flinketl.facade.impl.ExecuteEngineFacadeImpl.process(ExecuteEngineFacadeImpl.java:83) at com.taimeitetch.flinketl.process.FlinkETLProcess.main(FlinkETLProcess.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529) at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421) at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:423) at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:813) at org.apache.flink.client.cli.CliFrontend.runProgram(CliFrontend.java:287) at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:213) at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1050) at org.apache.flink.client.cli.CliFrontend.lambda$main$11(CliFrontend.java:1126) at org.apache.flink.runtime.security.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30) at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1126) Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 916,696 milliseconds ago. The last packet sent successfully to the server was 916,697 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3652) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2460) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)

注意:我使用navicat读写该tidb时没有任何问题

以下是我连接池的一些参数: jdbc.maxConnectionsPerPartition=4 jdbc.minConnectionsPerPartition=3 jdbc.partitionCount=3 jdbc.acquireIncrement=5 jdbc.poolAvailabilityThreshold=20

jdbc.idleMaxAgeInMinutes=600 jdbc.connectionTimeoutInMs=600000 jdbc.idleConnectionTestPeriodInMinutes=100 jdbc.maxConnectionAgeInSeconds=36000

1、从报错直观上看是应用端的报错,不是数据库的本身的 err 信息

2、如果是出现这个报错,建议在数据库端看下 wait-time,以及 interactive_timeout 参数设置。

3、看下应用服务器到 tidb 间是否有防火墙,防火墙是否设置了空闲连接的回收

1、tidb服务器确实正常的;

2、tidb库没有wait-time这个变量,是指wait_timeout?

3、应用服务器至tidb之间没有防火墙

可以单独建一个链接,测试下看看,是否是 tidb 端回收链接导致的报错。

在测试前,前确认下 wait_time,以及 interactive_timeout 是否为 0.