当前位置:网站首页>Mysql client common exception analysis
Mysql client common exception analysis
2022-07-30 06:55:00 【If I don't see you tomorrow】
SocketTimeoutException
jdbc timeout包括Transaction Timeout/Statement Timeout/connectTimeout/socketTimeout四种类型,详细解释可见Jdbc & Mysql timeout分析
如果与服务器连接成功,The data transfer starts.如果服务器处理数据用时过长,超过了socketTimeout,就会抛出SocketTimeOutExceptin,即服务器响应超时
建议在jdbc url param中显示配置connectTimeout/socketTimeout,有效控制MySQL处理时间,并释放连接
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&connectTimeout=3000&socketTimeout=5000
CommunicationsException
若发生 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 异常,Failed to connect to the database,But there can be multiple reasons for failure,roughly the same mysql 各种 timeout 参数相关
EOFException
net_write_timeout 控制 mysql serverTimeout for writing data to the client.If the client establishes a connection,超过该时间MySQLData has not been written yet,则会抛出EOFException
java.io.EOFException: Can not read response from server. Expected to read 34328 bytes, read 433 bytes before connection was unexpectedly lost.
SocketException
jdbcConnection will be based on mysql wait_timeout 检测空闲连接.若在 wait_timeout 时间内,The connection is still idle,mysql serverThis link will be broken.
与
MySQL建立连接成功后,MySQL主动断开连接,The underlying exception isjava.net.SocketException: Software caused connection abort: recv failed
SocketTimeoutException
sql执行时间超过socketTimeout的配置,则会抛出java.net.SocketTimeoutException: Read timed out
RecoverableDataAccessException
Disconnected is usedMySQL连接,会抛出org.springframework.dao.RecoverableDataAccessException
附表(MySQL timeout参数)
SHOW VARIABLES LIKE '%timeout%';可查看MySQL timeout参数
| 参数 | 描述 | 功能 |
|---|---|---|
| connect_timeout | 连接响应超时时间 | 服务器端在这个时间内如未连接成功,则会返回连接失败. |
| wait_timeout | 连接空闲超时时间 | 与服务器端无交互状态的连接,直到被服务器端强制关闭而等待的时间.It can be considered as the idle time of the server-side connection,If idle for more than this time, it will automatically shut down |
| interactive_timeout | 连接空闲超时时间 | 与服务器端无交互状态的连接,直到被服务器端强制关闭而等待的时间. |
| net_read_timeout | 数据读取超时时间 | before terminating the read,The number of seconds to wait to get data from a connection;When the service is reading data from the client,net_read_timeoutControls when to time out.That is, the client performs data reading,How many seconds to wait for automatic disconnection if still unsuccessful. |
| net_write_timeout | 数据库写超时时间 | 和net_read_timeout意义类似,before terminating the write,How many seconds to waitblockWrite to the connection;When the service is writing data to the client,net_write_timeoutControls when to time out. |
| slave-net-timeout | The time to delay synchronization from the library | 当slavethink connectedmasterwhen there is a problem with the connection,就等待N秒,然后断开连接,重新连接master |
interactive_timeout和wait_timeoutThe meaning is the same though,But there are essential differences in using objects.interactive_timeout针对交互式连接(比如通过mysql客户端连接数据库),wait_timeout针对非交互式连接(Like generallyPHP中使用PDO连接数据库,当然你可以设置CLIENT_INTERACTIVE选项来改变).所谓的交互式连接,即在mysql_real_connect()函数中使用了CLIENT_INTERACTIVE选项.
slave-net-timeoutWorks on slave libraries when master-slave is synchronized;connect_timeout:在获取连接阶段起作用;interactive_timeout和wait_timeout:Works during connection idle phase;net_read_timeout和net_write_timeout:It works when the connection is executed.
参考文档:
边栏推荐
- Jackson serialization failure problem - oracle data return type can't find the corresponding Serializer
- Flink PostgreSQL CDC配置和常见问题
- The Request request body is repackaged to solve the problem that the request body can only be obtained once
- 利用自定义注解,统计方法执行时间
- npm安装和npm安装——保存
- 【MySQL功法】第5话 · SQL单表查询
- Usage of exists in sql
- Powerhouse Cup Preliminary WP
- [Ten years of network security engineers finishing] - 100 penetration testing tools introduction
- MySQL achievement method 】 【 5 words, single table SQL queries
猜你喜欢
随机推荐
在线sql编辑查询工具sql-editor
JVM Learning (2) Garbage Collector
mysql不是内部或外部命令,也不是可运行的程序或批处理文件解决
Flink PostgreSQL CDC配置和常见问题
Nacos配置中心用法详细介绍
3分钟告诉你如何成为一名黑客|零基础到黑客入门指南,你只需要掌握这五点能力
PHP-fpm
【数仓】数据仓库高频面试题题英文版(1)
Servlet basic principles and application of common API methods
Misc-traffic analysis of CTF
MYSQL一站式学习,看完即学完
Extraction of BaseDAO
网上说的挖矿究竟是什么? 挖矿系统开发详解介绍
Bubble sort, selection sort, insertion sort, quick sort
【零基础搞定C语言——导航汇总篇】
TDengine集群搭建
MySQL开窗函数
SQL Server Installation Tutorial
史上超强最常用SQL语句大全
Redis 客户端常见异常分析








