在 rake 任务中接收 "ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out"
Receiving "ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out" in rake task
在我的 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)
我在我的 config/database.yml
文件中禁用了准备好的语句,并在我的 pgbouncer 配置文件中启用了 transaction
pool_mode
。
当我直接连接到 postgres 时,我没有收到此错误。
同样在我的 rake 任务中,我正在创建多个线程。我按照建议 here 在我的线程中尝试了 运行 ActiveRecord::Base.connection.reconnect!
。这也没有帮助。
我正在使用 rails 版本 4.2.5,其中有 this fix。我仍然收到此错误 "could not receive data from server: Connection timed out".
这是由于客户端的网络问题造成的。无法重现,因为我们将服务器和客户端都迁移到了 Google Cloud Platform。早些时候我们的服务器在 DigitalOcean 中,而我们的客户在 GCP 中。
在我的 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)
我在我的 config/database.yml
文件中禁用了准备好的语句,并在我的 pgbouncer 配置文件中启用了 transaction
pool_mode
。
当我直接连接到 postgres 时,我没有收到此错误。
同样在我的 rake 任务中,我正在创建多个线程。我按照建议 here 在我的线程中尝试了 运行 ActiveRecord::Base.connection.reconnect!
。这也没有帮助。
我正在使用 rails 版本 4.2.5,其中有 this fix。我仍然收到此错误 "could not receive data from server: Connection timed out".
这是由于客户端的网络问题造成的。无法重现,因为我们将服务器和客户端都迁移到了 Google Cloud Platform。早些时候我们的服务器在 DigitalOcean 中,而我们的客户在 GCP 中。