Hi,
We're using reliable-msg on Ubuntu with:
ruby 1.8.4-1ubuntu1.3
libdbd-mysql-ruby 0.0.23-3
libmysql-ruby 2.7-1.1build2
We're storing and retrieving messages from a Rails application into a queue backed by a MySQL store and seeing intermittent errors that look like the following:
Mysql::Error (MySQL server has gone away):
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/message-store.rb:530:in `query'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/message-store.rb:530:in `load_index'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/message-store.rb:102:in `transaction'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/queue-manager.rb:350:in `queue'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1512:in `perform'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1427:in `run'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1424:in `run'
(druby://localhost:6438) /usr/lib/ruby/1.8/drb/drb.rb:1344:in `initialize'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/queue-manager.rb:238:in `start'
(druby://localhost:6438) /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/queue-manager.rb:217:in `start'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/cli.rb:109:in `run'
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/bin/queues:7
(druby://localhost:6438) /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'
(druby://localhost:6438) /usr/bin/queues:18
/usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/queue.rb:147:in `put'
/usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/client.rb:128:in `repeated'
/usr/lib/ruby/gems/1.8/gems/reliable-msg-1.1.0/lib/reliable-msg/queue.rb:147:in `put'
/app/services/reliable_msg_queue_facade.rb:9:in `put'
/app/controllers/register_controller.rb:31:in `update'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:84:in `process'
/usr/lib/ruby/1.8/sync.rb:229:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:83:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:580:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:579:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `run'
and so on.
Wondering if you had experienced this or know if we're doing something wrong. Reading through the code for message_store.rb it seems like the MySQL#connect method creates a new Mysql instance if the value in the current thread is nil, but doesn't check to see if the connection within the current thread's Mysql instance is actually alive or not. I'm referring to the following code:
def connection
Thread.current[THREAD_CURRENT_MYSQL] ||= Mysql.new @config[:host], @config[:username], @config[:password], @config[:database], config[:port], @config[:socket]
end
|