繁体   English   中英

接收“ActiveRecord :: StatementInvalid:PG :: ConnectionBad:PQconsumeInput()无法从服务器接收数据:连接超时”在rake任务中

[英]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文件中禁用了pool_mode准备语句,并在我的pgbouncer配置文件中启用了transaction pool_mode 当我直接连接到postgres时,我没有收到此错误。

同样在我的rake任务中,我正在创建多个线程。 我试过运行ActiveRecord::Base.connection.reconnect! 在我的线程内部,如此处所示 这也没有帮助。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM