1. 程式人生 > >PostgreSQL,問題排查:Acquistion Attempt Failed!!! Clearing pending acquires. While trying to acquire ...

PostgreSQL,問題排查:Acquistion Attempt Failed!!! Clearing pending acquires. While trying to acquire ...

Acquistion Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts(30).

......

This ResultSet is closed.

 

排查思路:

1、資料庫沒有連上,檢查資料庫配置;

2、網路不穩定,資料庫時而連上時而斷開連線;

3、使用者數達到配置上限導致連不上:

通過在資料庫連線工具Navicat(或是別的工具),在資料庫中查詢“當前連線數”和“最大允許連線數”,sql如下:

show count(*) from pg_stat_activity;--查詢當前連線數

show max_connections;--查詢最大連線數

(也可檢視postgresql配置檔案檢視最大連線數:postgresql.auto.conf和postgresql.conf)

4、資料庫驅動和資料庫版本不匹配導致;

如果你的專案是maven來管理依賴包的話,可以修改maven中資料庫驅動依賴包,使用較高版本(可匹配資料庫版本)的依賴包。

 

實際排查:

專案和資料庫部署在同一套伺服器,不存在網路問題;於是我就檢查了資料庫連線數問題,當前連線數9,最大允許連線數2000;於是我檢查了資料庫版本,與驅動,發現數據庫版本較高,而驅動比較低,我換了高版本驅動,問題得到了解決。

 

希望能幫到你們!