Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of MySQL and timeout

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the MySQL and timeout example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Here is a summary of the timeout related to the connection

Slave-net-timeout

The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect. The first retry occurs immediately after the timeout. The interval between retries is controlled by the MASTER_CONNECT_RETRY option for the CHANGE MASTER TO statement, and the number of reconnection attempts is limited by the-- master-retry-count option. The default is 3600 seconds (one hour).

When slave thinks there is something wrong with the connection to the master, wait N seconds, then disconnect and reconnect the master

Net_read_timeout:

The number of seconds to wait for more data from a connection before aborting the read. When the server is reading from the client, net_read_timeout is the timeout value controlling when to abort

The number of seconds to wait to get data from a connection before terminating the read; net_read_timeout controls when the timeout occurs when the service is reading data from the client.

Net_write_timeout:

The number of seconds to wait for a block to be written to a connection before aborting the write.When the server is writing to the client, net_write_timeout is the timeout value controlling when to abort .

How many seconds to wait for the block to be written to the connection before terminating the write; net_write_timeout controls when the timeout occurs when the service is writing data to the client

Wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.

A connection that has no interactive state with the server side until it is forcibly shut down by the server side and the waiting time

Interactive_timeout:

The number of seconds the server waits for activity on an interactive connection before closing it.

A connection that has no interactive state with the server side until it is forcibly shut down by the server side and the waiting time

Connect_timeout

The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds.

The time to wait for a connection to respond

Connect_timeout: works in the acquisition connection phase (authenticate)

Interactive_timeout and wait_timeout: working in the connection idle phase (sleep)

Net_read_timeout and net_write_timeout: it works during the connection busy phase (query).

Obtaining a MySQL connection is the result of multiple handshakes. In addition to the matching check of username and password, there is also IP- > HOST- > DNS- > IP verification. Any step may cause thread blocking due to network problems. To prevent threads from wasting on unnecessary parity waits, connection requests that exceed the connect_timeout will be rejected.

Even if there are no network problems, the client cannot be allowed to occupy the connection all the time. For clients that keep the sleep state beyond the wait_timeout (or interactive_timeout, depending on the client_interactive flag), MySQL actively disconnects.

Even if the connection is not in the sleep state, that is, the client is busy calculating or storing data, MySQL chooses to wait conditionally. During the distribution of a packet, the client may not have time to respond (sending, receiving, or processing the packet is too slow). In order to ensure that the connection is not wasted in endless waiting, MySQL will also choose to actively disconnect conditionally (net_read_timeout and net_write_timeout).

Thank you for reading this article carefully. I hope the article "sample Analysis of MySQL and timeout" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report