0

Background: I am new to ruby on rails and I have created an app that reads data from mysql database and displays patient information using dashing.

Problem: Whenever I refresh dashboard page more than 4 times I get an ActiveRecord::ConnectionTimeoutError. I strongly believe that connections are not getting closed, as read here. I tried to implement solutions given with little success.

Question/Request: Could you explain to me what has to be done in order to remove this bug ?

Thank you for help

EDIT

Redis-cli monitor output after two refreshes

EDIT2

Gem list:

  • gem 'devise'
  • gem 'rails', '4.2.5'
  • gem 'mysql2', '>= 0.3.13', '< 0.5'
  • gem 'sass-rails', '~> 5.0'
  • gem 'uglifier', '>= 1.3.0'
  • gem 'coffee-rails', '~> 4.1.0'
  • gem 'coffee-script-source', '1.8.0'
  • gem 'jquery-rails'
  • gem 'turbolinks'
  • gem 'jbuilder', '~> 2.0'
  • gem 'sdoc', '~> 0.4.0', group: :doc
  • gem 'dashing-rails'
  • gem 'puma'
  • gem 'nokogiri'
  • gem 'htmlentities'
  • gem 'pickadate-rails'
  • gem 'json'

Full error

Community
  • 1
  • 1

1 Answers1

0

You say you are using MySQL, but the post you linked to refers to Redis. You haven't really provided enough information to solve the problem, and the information you've provided is contradictory. That said, you can give yourself more confidence in your belief by connecting your MySQL server and running the command:

show processlist;

Run it once before you start the app. Load your page, and run it again every time you refresh the page. If you're not closing connections, you'll see a new connection each time.

Now, I find this explanation a little unlikely. It seems more likely to me you're doing something expensive and overloading the database. For that you would need to dig into what queries you're running and figure out how to optimize.

Luke Schlather
  • 367
  • 2
  • 13
  • I use MySQL to store data, however I still need Redis to run dashing. When I tried what you said no new connections were added in mysql in Redis however I get new subscription everytime I refresh the page (http://imgur.com/jy3oRXY). – Domen Lušina Apr 19 '16 at 15:38
  • ActiveRecord::ConnectionTimeoutError implies that your connection to MySQL timed out, not Redis. (Assuming that you're using the Mysql2 gem and not some Redis adapter. You should list the gems you're using and maybe your database configuration.) – Luke Schlather Apr 20 '16 at 23:08
  • Updated description. My database configurations are default. – Domen Lušina Apr 21 '16 at 00:08
  • Found out additional information that confirm my assumption [here](http://stackoverflow.com/questions/23119702/activerecordconnectiontimeouterror-due-to-unreleased-activerecord-connections). Issue turns out to be related to Rails 4 live stream ( Live streaming threads are not closing) – Domen Lušina Apr 21 '16 at 11:44