Mysql classic "8-hour problem" and mysql Classic 8-hour Problem

Source: Internet
Author: User

Mysql classic "8-hour problem" and mysql Classic 8-hour Problem

Assume that your database is mysql. If the data source is improperly configured, the classic "8-hour problem" may occur ". The reason is that by default, if a connection is idle for more than 8 hours, the connection will be automatically closed on the Database End. The data source does not know that the connection has been closed. When it returns this useless connection to a dao, dao will report that the connection cannot be obtained.

If the default configuration of dbcp is used, because the default value of testOnBorrow is true, the data source checks whether the connection is correct before handing over the connection to dao, if there is a problem with the connection (the database is closed), a different connection will be taken to dao. Therefore, there will be no "8-hour problem ". If the connection validity is checked every time the connection is handed over to dao, performance problems will occur in highly concurrent applications because it requires more database access requests.

We recommend that you set testOnBorrow to false, testWhileIdle to true, and testBetweenEvictionRunsMillis (less than 8 hours ). Do not clear the connections that are closed by mysql to avoid the "eight-hour problem ".

Of course, mysql can also adjust the interactive-timeout (in seconds) configuration parameters to change the expiration time of idle connections. Therefore, when setting the timeBetweenEvictionRunsmMillis value, you must first know the maximum expiration time of the mysql idle connection.

For effective connection detection, see dbcp configuration.

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.