Search code examples
ruby-on-railsrubyredispumadashing

Dashing: connections not closing


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


Solution

  • 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.