在我的 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 。我仍然收到此错误“无法从服务器接收数据:连接超时”。