6

在我的 rake 任务中,我通过 pgbouncer 设置连接到 postgresql。对于某些查询,我收到此错误:

ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out

在我的 pgbouncer 日志中,我看到了这个条目:

closing because: client unexpected eof (age=3110)

我在我的文件中禁用了准备好的语句,并在我的 pgbouncer 配置文件中config/database.yml启用了。transaction pool_mode当我直接连接到 postgres 时,我没有收到此错误。

同样在我的 rake 任务中,我正在创建多个线程。我尝试按照这里ActiveRecord::Base.connection.reconnect!的建议在我的线程中运行。那也没有帮助。

我正在使用具有此修复程序的 rails 版本 4.2.5 。我仍然收到此错误“无法从服务器接收数据:连接超时”。

4

1 回答 1

1

这是由于客户端中的网络问题引起的。由于我们将服务器和客户端都迁移到了 Google Cloud Platform,因此无法重现。早些时候,我们的服务器在 DigitalOcean 中,而我们的客户端在 GCP 中。

于 2016-10-25T08:05:14.243 回答