- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會(huì )理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構許可:滇D3-20230001
- 代理域名注冊服務(wù)機構:新網(wǎng)數碼
MySQL 數據庫連接超時(shí)的報錯
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 ‘a(chǎn)utoReconnect=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 的同學(xué),可能都會(huì )被開(kāi)發(fā)人員告知,你們的數據庫報了這個(gè)錯誤了,趕緊看看是哪里的問(wèn)題。
這個(gè)問(wèn)題是由兩個(gè)參數影響的,wait_timeout 和 interactive_timeout。
數據默認的配置時(shí)間是 28800(8小時(shí))意味著(zhù),超過(guò)這個(gè)時(shí)間之后,MySQL 數據庫為了節省資源,就會(huì )在數據庫端斷開(kāi)這個(gè)連接,MySQL 服務(wù)器端將其斷開(kāi)了,但是我們的程序再次使用這個(gè)連接時(shí)沒(méi)有做任何判斷,所以就掛了。
解決思路:先要了解這兩個(gè)參數的特性,這兩個(gè)參數必須同時(shí)設置,而且必須要保證值一致才可以。
我們可以適當加大這個(gè)值,8 小時(shí)太長(cháng)了,不適用于生產(chǎn)環(huán)境。因為一個(gè)連接長(cháng)時(shí)間不工作,還占用我們的連接數,會(huì )消耗我們的系統資源。
解決方法:可以適當在程序中做判斷,強烈建議在操作結束時(shí)更改應用程序邏輯以正確關(guān)閉連接,然后設置一個(gè)比較合理的 timeout 的值(根據業(yè)務(wù)情況來(lái)判斷)。
售前咨詢(xún)
售后咨詢(xún)
備案咨詢(xún)
二維碼
TOP