当前位置:网站首页>Jdbc & Mysql timeout analysis
Jdbc & Mysql timeout analysis
2022-07-30 06:55:00 【If I don't see you tomorrow】
Due to the structure of TPC/IP, there is no way for socket to detect network errors, so the application cannot detect if the connection to the database has been dropped.If the socket timeout is not set, the application will wait for the database to return the result.This article will summarize the timeout parameters and descriptions of Jdbc and MySQL.
Jdbc Connection

Jdbc timeout

Transaction Timeout
Transaction timeout parameter.The time for executing data submission is limited, and an exception will be thrown if the timeout value exceeds the set value.
Statement Timeout
Used to limit the execution time of the statement query.Set by calling JDBC's java.sql.Statement.setQueryTimeout(in timeout) API
connectTimeout
Configure the connection timeout period.Configure by Socket.connect(SocketAddress endpoint, int timeout) method
If the time to establish a connection with the server (here) request exceeds
connectTimeout, it will throwConnectionTimeOutException
socketTimeout
Configure the Socket timeout.Set by Socket.setSoTimeout(int timeout)
If the connection to the server is successful, the data transfer starts.If the server takes too long to process data and exceeds
socketTimeout, it will throwSocketTimeOutExceptin, that is, the server response timed out
Mysql timeout
| parameter | Description | Features |
|---|---|---|
| connect_timeout | Connection response timeout | If the server fails to connect successfully within this time, it will return a connection failure. |
| wait_timeout | Connection idle timeout | The time to wait for a connection without interaction with the server until it is forcibly closed by the server.It can be considered as the idle time of the server-side connection. If the idle time exceeds this time, it will be automatically closed. |
| interactive_timeout | Connection idle timeout | The time to wait for a connection without interaction with the server until it is forcibly closed by the server. |
| net_read_timeout | Data read timeout | The number of seconds to wait to get data from a connection before terminating the read; net_read_timeout controls when to time out when the service is reading data from the client.That is, the client performs data reading, and automatically disconnects after waiting for how many seconds before the execution is successful. |
| net_write_timeout | Database write timeout | Similar to net_read_timeout, how many seconds to wait to write the block to the connection before terminating the write; when the service is writing data to the client, net_write_timeout controls when it times out. |
| slave-net-timeout | Delay sync from library | When the slave thinks there is a problem with the connection to the master, it waits for N seconds, then disconnects and reconnects to the master |
interactive_timeoutandwait_timeouthave the same meaning, but there are essential differences in the objects used.Interactive_timeout is for interactive connections (such as connecting to the database through the mysql client), and wait_timeout is for non-interactive connections (such as using PDO to connect to the database in PHP, of course, you can set the CLIENT_INTERACTIVE option to change).The so-called interactive connection, that is, the CLIENT_INTERACTIVE option is used in the mysql_real_connect() function.
slave-net-timeoutworks on slave libraries during master-slave synchronization;connect_timeout: works during the connection acquisition phase;interactive_timeoutandwait_timeout: work during the idle phase of the connection;net_read_timeoutandnet_write_timeout: It works when the connection is executed.
References:
边栏推荐
猜你喜欢

二十一、Kotlin进阶学习:实现简单的网络访问封装

SQL Server 数据库之生成与执行 SQL 脚本

oracle row to column, column to row summary

FastAPI Quick Start

Nacos配置中心用法详细介绍

"MySQL Advanced Chapter" four, the storage structure of the index

Remember a Mailpress plugin RCE vulnerability recurrence

网上说的挖矿究竟是什么? 挖矿系统开发详解介绍
awd --waf deployment

MySQL - 函数及约束命令
随机推荐
学生成绩管理系统(C语言版)
sql concat()函数
在不同的服务器上基于docker部署redis主从同步
DVWA installation tutorial (understand what you don't understand · in detail)
【OS】操作系统高频面试题英文版(1)
Competition WP in May
mysql is not an internal or external command, nor is it a runnable program or batch file to resolve
shardingsphere 分库分表及配置示例
MySQL 5.7 installation tutorial (all steps, nanny tutorials)
MySQL 数据类型及占用空间
Operators and Interaction Basics
vulnhub-XXE ctf security question
uni-app installs components using npm commands
[Mozhe Academy] Identity Authentication Failure Vulnerability Actual Combat
mysql delete duplicate data in the table, (retain only one row)
Communication middleware Fast DDS basic concepts and communication examples
Thread state of five
npm安装和npm安装——保存
kali is an essential artifact for information security
sql中 exists的用法