手机看片精品高清国产日韩,色先锋资源综合网,国产哺乳奶水91在线播放,乱伦小说亚洲色图欧洲电影

幫助中心 >  技術知識庫 >  數據庫 >  數據庫管理 >  MySQL數據庫經典錯誤 十一 MySQL 數據庫連接超時的報錯

MySQL數據庫經典錯誤 十一 MySQL 數據庫連接超時的報錯

2018-11-08 20:26:00 22801

MySQL 數據庫連接超時的報錯

org.hibernate.util.JDBCExceptionReporter – SQL Error:0, SQLState: 08S01 
org.hibernate.util.JDBCExceptionReporter – The last packet successfully received from the server was43200 milliseconds ago.The last packet sent successfully to the server was 43200 milliseconds ago, which is longer than the server configured value of ‘wait_timeout’. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection ‘autoReconnect=true’ to avoid this problem. 
org.hibernate.event.def.AbstractFlushingEventListener – Could not synchronize database state with session 
org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update 
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state. 
org.hibernate.util.JDBCExceptionReporter – SQL Error:0, SQLState: 08003 
org.hibernate.util.JDBCExceptionReporter – No operations allowed after connection closed. Connection was implicitly closed due to underlying exception/error: 
** BEGIN NESTED EXCEPTION **

大多數做 DBA 的同學,可能都會被開發人員告知,你們的數據庫報了這個錯誤了,趕緊看看是哪里的問題。

這個問題是由兩個參數影響的,wait_timeout 和 interactive_timeout。

數據默認的配置時間是 28800(8小時)意味著,超過這個時間之后,MySQL 數據庫為了節省資源,就會在數據庫端斷開這個連接,MySQL 服務器端將其斷開了,但是我們的程序再次使用這個連接時沒有做任何判斷,所以就掛了。

解決思路:先要了解這兩個參數的特性,這兩個參數必須同時設置,而且必須要保證值一致才可以。

我們可以適當加大這個值,8 小時太長了,不適用于生產環境。因為一個連接長時間不工作,還占用我們的連接數,會消耗我們的系統資源。

解決方法:可以適當在程序中做判斷,強烈建議在操作結束時更改應用程序邏輯以正確關閉連接,然后設置一個比較合理的 timeout 的值(根據業務情況來判斷)。


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: