首页 > 数据库 >MySQL出现客户端连接超时异常

MySQL出现客户端连接超时异常

时间:2022-08-30 08:56:21浏览次数:227  
标签:java flink streaming MySQL apache org 超时 com 客户端

一、错误日志

2022-08-30 03:14:45
org.apache.flink.streaming.runtime.tasks.AsynchronousException: Caught exception while processing timer.
    at org.apache.flink.streaming.runtime.tasks.StreamTask$StreamTaskAsyncExceptionHandler.handleAsyncException(StreamTask.java:1214)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.handleAsyncException(StreamTask.java:1190)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invokeProcessingTimeCallback(StreamTask.java:1329)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.lambda$null$17(StreamTask.java:1318)
    at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50)
    at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90)
    at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317)
    at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:189)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:619)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:583)
    at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:758)
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:573)
    at java.lang.Thread.run(Thread.java:748)
Caused by: TimerException{org.apache.flink.streaming.runtime.tasks.ExceptionInChainedOperatorException: Could not forward element to next operator}
    ... 11 more
Caused by: org.apache.flink.streaming.runtime.tasks.ExceptionInChainedOperatorException: Could not forward element to next operator
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:88)
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:46)
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:26)
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:50)
    at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:28)
    at org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:50)
    at org.apache.flink.streaming.api.functions.windowing.PassThroughAllWindowFunction.apply(PassThroughAllWindowFunction.java:35)
    at org.apache.flink.streaming.runtime.operators.windowing.functions.InternalSingleValueAllWindowFunction.process(InternalSingleValueAllWindowFunction.java:48)
    at org.apache.flink.streaming.runtime.operators.windowing.functions.InternalSingleValueAllWindowFunction.process(InternalSingleValueAllWindowFunction.java:34)
    at org.apache.flink.streaming.runtime.operators.windowing.WindowOperator.emitWindowContents(WindowOperator.java:577)
    at org.apache.flink.streaming.runtime.operators.windowing.WindowOperator.onProcessingTime(WindowOperator.java:533)
    at org.apache.flink.streaming.api.operators.InternalTimerServiceImpl.onProcessingTime(InternalTimerServiceImpl.java:284)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.invokeProcessingTimeCallback(StreamTask.java:1327)
    ... 10 more
Caused by: java.sql.SQLException: connection disabled
    at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1185)
    at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1170)
    at com.alibaba.druid.pool.DruidPooledConnection.setAutoCommit(DruidPooledConnection.java:718)
    at com.meiyijia.pd.flink.meta.sink.dwd.MySQLSinkToOptions.invoke(MySQLSinkToOptions.java:73)
    at com.meiyijia.pd.flink.meta.sink.dwd.MySQLSinkToOptions.invoke(MySQLSinkToOptions.java:21)
    at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:54)
    at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:71)
    ... 22 more
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 41,094,955 milliseconds ago. The last packet sent successfully to the server was 41,094,955 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2056)
    at com.alibaba.druid.pool.DruidPooledConnection.setAutoCommit(DruidPooledConnection.java:729)
    at com.meiyijia.pd.flink.meta.sink.dwd.MySQLSinkToOptions.invoke(MySQLSinkToOptions.java:38)
    ... 25 more
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: The last packet successfully received from the server was 41,094,955 milliseconds ago. The last packet sent successfully to the server was 41,094,955 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    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.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
    at com.mysql.cj.protocol.a.NativeProtocol.send(NativeProtocol.java:569)
    at com.mysql.cj.protocol.a.NativeProtocol.sendCommand(NativeProtocol.java:624)
    at com.mysql.cj.protocol.a.NativeProtocol.sendQueryPacket(NativeProtocol.java:940)
    at com.mysql.cj.protocol.a.NativeProtocol.sendQueryString(NativeProtocol.java:886)
    at com.mysql.cj.NativeSession.execSQL(NativeSession.java:1073)
    at com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2046)
    ... 27 more
Caused by: java.net.SocketException: Broken pipe (Write failed)
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at com.mysql.cj.protocol.a.SimplePacketSender.send(SimplePacketSender.java:55)
    at com.mysql.cj.protocol.a.TimeTrackingPacketSender.send(TimeTrackingPacketSender.java:50)
    at com.mysql.cj.protocol.a.NativeProtocol.send(NativeProtocol.java:560)
    ... 32 more

二、原因分析

  客户端连接超时,请设置客户端超时时间wait_timeout或配置连接失效后自动连接autoReconnect=true

三、解决

1、mysql5以上的,设置autoReconnect=true 是无效的 只有4.x版本,起作用

2、即使在创建Mysql时url中加入了autoReconnect=true参数,一但这个连接两次访问数据库的时间超出了服务器端wait_timeout的时间限制,还是会CommunicationsException: The last packet successfully received from the server was xxx milliseconds ago.

3、服务器端的参数可以用如下参数进行设置,但是wait_timeout值不应该设的太高

show global variables like 'wait_timeout';
set global wait_timeout=10;

4、较好的策略是对处于idle状态的connection定时发送一个sql,来刷新服务器上的时间戳.这可以使用c3p0r的连接,如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接, mysql数据库有一个wait_timeout的配置,默认值为28800(即8小时). 在默认配置不改变的情况下,如果连续8小时内都没有访问数据库的操作,再次访问mysql数据库的时候,mysql数据库会拒绝访问

四、参考地址

https://blog.csdn.net/qq_21137441/article/details/102916199

标签:java,flink,streaming,MySQL,apache,org,超时,com,客户端
From: https://www.cnblogs.com/qq1035807396/p/16638081.html

相关文章

  • 【MySQL】DDL因Waiting for table metadata lock卡住
    在数据库空闲时间,对表做碎片整理:altertablemy_abcengine=innodb;发现会话被阻塞,显示状态是:Waitingfortablemetadatalock 手动断开alter操作后,通过showpr......
  • MySQL无法重启报错Warning: World-writable config file ‘/etc/my.cnf’ is ignored
    MySQL无法重启报错Warning:World-writableconfigfile‘/etc/my.cnf’isignored的解决方法_Mysql_脚本之家 https://www.jb51.net/article/99027.htm问题分析在关......
  • 1.Docker下搭建MySQL主从复制(一主一从)
    Docker下搭建MySQL主从复制(一主一从)实现Mycat读写分离1、通过dockerexec-it627a2368c865/bin/bash命令进入到Master容器内部2、cd/etc/mysql切换到/etc/mysql目录......
  • MySQL的sql_mode设置导致报错1292
    在MySQL8.0的一个PXC集群中,默认的sql_mode设置如下:select@@sql_mode;+-------------------------------------------------------------------------------------------......
  • MySQL低配数据库被大量数据导入时KO
    在一个低配MySQL数据库(笔记本电脑虚机环境,虚机配置2CPU/3G内存),在3000万级别的大量数据LOADDATA方式导入时,坚持一小时后,终于被KO了,甚至没写下任何有用的日志,只是在操作界面......
  • MySQL快速导入千万条数据(3)
    接上文,本次在较高性能的X86物理机上,做真实生产环境的大数据量导入测试。一、测试环境■CPU是24核,每核2线程,即48CPU$lscpuArchitecture:x86_64CPUop-mode......
  • MySQL快速导入千万条数据(2)
    接上文,继续测试3000万条记录快速导入数据库。一、导入前1000万条数据清库、建库、新建表结构、导入前1000万条数据,结果:■1000万行,有2索引导入耗时:16分钟QueryOK,999......
  • MySQL快速导入千万条数据(1)
    对于传统的关系数据库如oracle,在大量数据导入方面的效率,我们一般有一个大概的认知,即1分钟以内可以导入千万条数据,而对于MySQL数据库,普遍观点以为性能相对较差,尤其时对于千......
  • MySQL PXC集群大事务提交超限
    研发人员在测试大事务提交时遇见了错误:Goterror5-'Transactionsizeexceedsetthreshold'duringCOMMIT测试了几次都是1200S的时候停止的,不过在注释掉特定步骤后,......
  • 基本的mysql语句
    基本的mysql语句  本节课先对mysql的基本语法初体验。操作文件夹(库)增createdatabasedb1charsetutf8;查#查看当前创建的数据库showcreatedatabase......