2016-04-28 54 views
2

根據https://pgbouncer.github.io/usage.html運行KILL db;應該立即刪除給定數據庫上的所有客戶端和服務器連接。 我試圖用pgbouncer kill命令塊後續連接

=# kill postgres; 

停止對我的測試環境的Postgres所有的連接,它真的關閉了所有客戶端和服務器的連接,但我無法連接到Postgres的了。

$ psql -h localhost -p 6543 postgres 
psql: ERROR: pgbouncer cannot connect to server 

在postgresql.log我有以下消息

[2016-04-27 16:21:38 u=postgres d=postgres h=[local] p=12458 l=1] LOG: could not send data to client: Broken pipe 
[2016-04-27 16:21:38 u=postgres d=postgres h=[local] p=12458 l=2] FATAL: connection to client lost 

pgBouncer realod不改變這種狀況,只有重新啓動幫助。

=# show databases; 
name  │ host │ port │ database │ force_user │ pool_size │ reserve_pool │ pool_mode │ max_connections │ current_connections 
─────────┼──────┼──────┼──────────┼────────────┼───────────┼──────────────┼───────────┼─────────────────┼───────────────────── 

postgres │ NULL │ 5454 │ postgres │ NULL  │   5 │ 100   │ NULL  │ 0    │ 0 


=# show version; 
NOTICE: pgbouncer version 1.7.2 
  1. 任何人能解釋發生了什麼事?
  2. 有沒有辦法通過pgbouncer修復postgres連接而不重新啓動?
  3. 如果數據庫連接鎖定是預期的kill命令行爲,如何關閉所有連接而不阻止新連接?

感謝,米哈伊爾

回答

1

使用恢復命令pgBouncer。

這在pgBouncer的關於Process Controlling Commands的部分沒有準確記錄,但KILL db;命令實際上需要後續的RESUME db;命令來允許連接。

如果你看看你的pgBouncer日誌文件,你應該看到條目是這樣的:

2016-12-16 22:07:10.224 5720 LOG C-0x851e28: dbname/[email protected]:42421 login attempt: db=dbname user=username tls=no 2016-12-16 22:07:10.224 5720 LOG C-0x851e28: dbname/[email protected]:42421 closing because: pgbouncer cannot connect to server (age=0) 2016-12-16 22:07:10.224 5720 WARNING C-0x851e28: dbname/[email protected]:42421 Pooler Error: pgbouncer cannot connect to server 2016-12-16 22:07:10.224 5720 LOG S-0x85aae0: dbname/[email protected](bad-af):0 closing because: pause mode (age=0)

注意pgBouncer聲稱它是在暫停模式在該日誌中,我看到了同樣的錯誤通過psql的報道,而正是在這樣的狀態:

psql: ERROR: pgbouncer cannot connect to server

一個RESUME db;命令pgBouncer,連接到後ctions應該再次運作。