Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 404259 - www-servers/thin init script should (optionnaly?) depends on mysql
Summary: www-servers/thin init script should (optionnaly?) depends on mysql
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-17 14:39 UTC by Thomas Capricelli
Modified: 2012-02-18 02:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Capricelli 2012-02-17 14:39:03 UTC
When i restart mysql, all apps served by thin fail on the first hit because the mysql connection is closed. This looks like this in logs:

--------------------------------------------
ActiveRecord::StatementInvalid (Mysql::Error: MySQL server has gone away: SHOW FIELDS FROM `settings`):
  app/models/setting.rb:152:in `check_cache'
  app/controllers/application_controller.rb:58:in `user_setup'
  thin (1.2.11) lib/thin/connection.rb:84:in `pre_process'
  thin (1.2.11) lib/thin/connection.rb:82:in `catch'
  thin (1.2.11) lib/thin/connection.rb:82:in `pre_process'
  thin (1.2.11) lib/thin/connection.rb:57:in `process'
  thin (1.2.11) lib/thin/connection.rb:42:in `receive_data'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
  eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
  thin (1.2.11) lib/thin/backends/base.rb:61:in `start'
  thin (1.2.11) lib/thin/server.rb:159:in `start'
  thin (1.2.11) lib/thin/controllers/controller.rb:86:in `start'
  thin (1.2.11) lib/thin/runner.rb:185:in `send'
  thin (1.2.11) lib/thin/runner.rb:185:in `run_command'
  thin (1.2.11) lib/thin/runner.rb:151:in `run!'
  thin (1.2.11) bin/thin:6
  /usr/bin/thin:8:in `load'
  /usr/bin/thin:8
--------------------------------------------

For each site, there's one such error and then it works ok. My guess it that thin/rails has persistent mysql connections, which are re-created on errors such as this one.

So i think the init.d script should be modified so that restarting mysql will trigger a restart of thin, but i dont know how to do this..?

I understand not everybody uses mysql, so maybe this should be commented in the init.d script and people would optionnally uncomment it.
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2012-02-17 15:27:53 UTC
In this case you should set your own extra dependencies like this, in /etc/conf.d/thin:

rc_need="mysql"

The init script should not be changed.
Comment 2 Thomas Capricelli 2012-02-18 02:06:50 UTC
ok, i did not know that this was possible. This indeed fixes my issue.
Sorry for the noise.