根据https://pgbouncer.github.io/usage.html运行KILL db;
应该立即删除给定数据库上的所有客户端和服务器连接。
我试图在我的测试环境中停止所有与 postgres 的连接
=# kill 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
- 谁能解释发生了什么?
- 有没有办法通过 pgbouncer 修复 postgres-connection 而无需重新启动?
- 如果数据库连接锁定是 kill 命令的预期行为,我如何关闭所有连接而不阻塞新连接?
谢谢,米哈伊尔