gpt4 book ai didi

ruby-on-rails - Rails PgBouncer client_idle_timeout

转载 作者:行者123 更新时间:2023-12-04 15:47:06 29 4
gpt4 key购买 nike

我的问题是 pgbouncer 正在断开连接。系统管理员设置 client_idle_timeout 到 60 秒。对此,rails 方面有什么解决办法吗?我的意思是,是否有可能( gem 或设置)连接并断开连接(重新连接)到我们想要发送的每个查询的数据库?

ruby 2.0.0
rails 4.2.3
第 0.17.1 页

当连接超过 x 秒时,我收到以下错误(例如,当我打开 Rails 控制台时,等待 x 秒,然后对 db 运行一些 ActiveRecord 查询):

ERROR: client_idle_timeout
Contract Load (0.5ms) SELECT "contracts".* FROM "contracts" ORDER BY "contracts"."id" ASC LIMIT 1
PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly :
SELECT "contracts".* FROM "contracts" ORDER BY "contracts"."id" ASC LIMIT 1
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly :
SELECT "contracts".* FROM "contracts" ORDER BY "contracts"."id" ASC LIMIT 1

最佳答案

调用 ActiveRecord::Base.clear_active_connections!将过时的连接返回到线程池并检查新连接,这样您就不必重新启动控制台/服务器

关于ruby-on-rails - Rails PgBouncer client_idle_timeout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55240150/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com