MySQL frequently loses connection

: The first loop is executed sql is normal, as the number of cycles or increased execution time, execution began to lose the connection. Not forget to close the connection, the connection pool is useless, but a short time to lose in case of implementation of sql connection.

MySQL timeout parameters

A basic can see what it means, here introduces wait_timeout, net_read_timeout and net_write_timeout.

net_read_timeout: server reads (query) timeout operations.

net_write_timeout: timeout server writes.

the wait_timeout: timeout non-interactive operation, namely: idle timeout operation, such as long idle connections.

Question: ten thousand batch pagination execution cycle of updates, each with about sql 30s, the connection is lost.

Terminal modification net_write_timeout timeout is 300s, does not work, it does not contain the suspect writes update (feeling should not be).

Profile mysqld.cnf (can be in any [mysqld] profile) Modify the timeout wait_timeout and restart successfully solve connection timeout problem.

Personal feeling this case is set net_write_timeout should be able to work, suspected to be related to the session and global level, it is best to modify the configuration file, restart it.

 

 

 

 

Guess you like

Origin blog.csdn.net/ryuhfxz/article/details/92375087