关于ruby on rails:在rake任务中收到” ActiveRecord :: StatementInvalid:PG :: ConnectionBad:PQconsumeInput()无法从服务器接收数据:连接超时”

Receiving “ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out” in rake task

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

1
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could NOT receive DATA FROM server: Connection timed OUT

在我的pgbouncer日志中,看到以下条目:

1
closing because: client unexpected eof (age=3110)

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

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

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


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