onnectionTimeoutError由于未发布的Activ

onnectionTimeoutError由于未发布的Activ

本文介绍了ActiveRecord :: ConnectionTimeoutError由于未发布的ActiveRecord连接Dashing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dashing-rails(使用Rufus-scheduler)将更新发送到浏览器小部件。

在浏览器向页面发出5次不同的请求,因为:ActiveRecord :: ConnectionTimeoutError导致网站崩溃。



我的假设是每个浏览器equests触发器都会创建一个rufus调度器线程。这个线程发送更新并且线程保持在ActiveRecord连接上,而不会让它发生,最终导致超时。



然而,我试着确保计划释放连接到ActiveRecord池无济于事。

  Dashing.scheduler.every'10s',:allow_overlapping => false 
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地址:#{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连接上?解决方案

问题原来与Rails 4直播。



Rails 4中的直播流线程并未关闭。


I'm using Dashing-rails (which uses Rufus-scheduler) to send updates to a browser widget.

After 5 separate requests to the page from a browser, the site crashes due to: "ActiveRecord::ConnectionTimeoutError".

My hypothesis is that each browser equests triggers creating a rufus-scheduler thread. This thread sends out updates and the thread holds on to the ActiveRecord connection without letting it go, eventually causing a timeout.

However, I tried ensuring the schedule release the connection to the ActiveRecord pool to no avail.

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

Is there a way to see what processes are running on each thread/ what's holding the ActiveRecord connection? Or prevent Dashing-rails from holding on to the ActiveRecord connection if this is the issue?

解决方案

Issue turns out to be related to Rails 4 live stream.https://github.com/rails/rails/issues/10989

Specifically Live streaming threads in Rails 4 are not getting closed.

这篇关于ActiveRecord :: ConnectionTimeoutError由于未发布的ActiveRecord连接Dashing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 03:57