You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ActiveRecord::Base.connected?在数据库宕机后仍返回true的问题咨询

ActiveRecord::Base.connected? Returns True Even When Database Goes Down (After Initial Connection)

I've run into this quirky behavior with Rails' ActiveRecord: once your Rails app establishes an initial connection to the database (DB), calling ActiveRecord::Base.connected? will still return true even if the database later becomes unavailable or crashes.

Here's how you can reproduce this issue step by step:

  • Start your Rails application along with its database container (like Docker for PostgreSQL or MySQL)
  • Wait until the Rails app is fully up and running, confirming it's successfully connected to the DB
  • Stop the database container to simulate a database outage
  • Launch a rails console session
  • Check the return value of ActiveRecord::Base.connected? — you'll see it still returns true

内容的提问来源于stack exchange,提问作者Jimbali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:38:02