【问题标题】:ActiveRecord::ConnectionTimeoutError due to unreleased ActiveRecord connections by DashingActiveRecord::ConnectionTimeoutError 由于 Dashing 未释放 ActiveRecord 连接
【发布时间】:2014-05-31 22:21:28
【问题描述】:

我正在使用 Dashing-rails(它使用 Rufus-scheduler)向浏览器小部件发送更新。

在浏览器向页面发出 5 次单独请求后,站点由于以下原因而崩溃:“ActiveRecord::ConnectionTimeoutError”。

我的假设是每个浏览器请求触发器创建一个 rufus-scheduler 线程。该线程发送更新,并且线程保持 ActiveRecord 连接不放手,最终导致超时。

但是,我尝试确保计划释放与 ActiveRecord 池的连接无济于事。

Dashing.scheduler.every '10s', :allow_overlapping => false do
    ActiveRecord::Base.connection_pool.with_connection do
    Dashing.send_event('past_hour',   { value: Device.sightings_past_hour })

    d = Device.where("company != ''").last
    company = d.company !="" ? d.company : "Device Manufacturer Not Found"
    Dashing.send_event('last_MAC', { text: "#{company}",
                                 moreinfo: "MAC Address: #{d.macaddress}"})
    Dashing.send_event('macaddresses',   { current: Device.total_Count })
top_manufacturers=Device.manufacturers_dashboard
    Dashing.send_event('manufacturers', {items: top_manufacturers})
    Dashing.send_event('past_day',   { current: Device.sightings_past_day })
end
    ActiveRecord::Base.connection_pool.release_connection
end

有没有办法查看每个线程上正在运行的进程/什么保持 ActiveRecord 连接?如果这是问题,或者阻止 Dashing-rails 保持 ActiveRecord 连接?

【问题讨论】:

    标签: ruby-on-rails ruby activerecord heroku dashing


    【解决方案1】:

    问题原来与 Rails 4 直播有关。 https://github.com/rails/rails/issues/10989

    具体来说,Rails 4 中的实时流线程不会关闭。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-14
      • 2016-12-26
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-09
      • 1970-01-01
      相关资源
      最近更新 更多