【问题标题】:pgbouncer kill command blocks subsequent connectionspgbouncer kill 命令阻止后续连接
【发布时间】:2016-04-28 13:39:41
【问题描述】:

根据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
  1. 谁能解释发生了什么?
  2. 有没有办法通过 pgbouncer 修复 postgres-connection 而无需重新启动?
  3. 如果数据库连接锁定是 kill 命令的预期行为,我如何关闭所有连接而不阻塞新连接?

谢谢,米哈伊尔

【问题讨论】:

    标签: postgresql database-connection pgbouncer


    【解决方案1】:

    使用 Resume 命令来 pgBouncer。

    这在 pgBouncer 关于Process Controlling Commands 的部分中没有准确记录,但KILL db; 命令实际上需要后续的RESUME db; 命令来允许连接。

    如果您查看 pgBouncer 日志文件,您应该会看到如下条目:

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

    请注意,pgBouncer 在此日志中声称它处于 暂停模式,并且我看到 psql 在此状态下报告的相同错误:

    psql: ERROR: pgbouncer cannot connect to server

    在向 pgBouncer 发出RESUME db; 命令后,连接应该会再次工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-06
      • 1970-01-01
      • 1970-01-01
      • 2018-01-16
      • 2015-04-01
      • 1970-01-01
      • 2020-08-21
      • 1970-01-01
      相关资源
      最近更新 更多