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?