tchandy/octopus — Issue #55: Lost connection to MySQL server during
Author: elistemann
Created: 2011-11-10 13:29:12+00:00
State: open

Hi,

we are using Octopus for replication, which is mostly working fine, but sometimes we get an "Lost connection to MySQL server during query" (~ for 0.1% of the requests we get).

I found this post, which seems to be the issue we have: http://stackoverflow.com/questions/4983385/lost-connection-to-mysql-server-during-query-error-with-rails3-octopus-replicat

We already have reconnect: true in our config, but you were writing that this is only working with unicorn, but not with passenger.
Could you find a solution for passenger?

Our app stack:
--------------------
Rails 3.0.10
Octopus 0.3.4
Passenger 3.0.9
MySQL 5.1.41

Our shards.yml:
----------------------
octopus:
replicated: true
fully_replicated: true
verify_connection: true
environments:
- production

production:
slave1:
encoding: utf8
adapter: mysql
database: database
username: slave
password:
socket: /var/run/mysqld/mysqld.sock
reconnect: true

Backtrace:
---------------
…/active_record/connection_adapters/abstract_adapter.rb: 207:in `log_instrumentation'
…lib/active_record/connection_adapters/mysql_adapter.rb: 289:in `execute'
…lib/active_record/connection_adapters/mysql_adapter.rb: 633:in `select'
…rd/connection_adapters/abstract/database_statements.rb: 7:in `select_all'
…ive_record/connection_adapters/abstract/query_cache.rb: 56:in `select_all'
…le/ruby/1.8/gems/ar-octopus-0.3.4/lib/octopus/proxy.rb: 177:in `send'
…le/ruby/1.8/gems/ar-octopus-0.3.4/lib/octopus/proxy.rb: 177:in `send_queries_to_selected_slave'
…le/ruby/1.8/gems/ar-octopus-0.3.4/lib/octopus/proxy.rb: 140:in `method_missing'
…1.8/gems/activerecord-3.0.10/lib/active_record/base.rb: 473:in `find_by_sql_ActiveRecord_self_name_find_by_sql'
…gems/activerecord-3.0.10/lib/active_record/relation.rb: 64:in `to_a'
…rd-3.0.10/lib/active_record/relation/finder_methods.rb: 341:in `find_first'
…rd-3.0.10/lib/active_record/relation/finder_methods.rb: 122:in `first'
…rd-3.0.10/lib/active_record/relation/finder_methods.rb: 242:in `send'
…rd-3.0.10/lib/active_record/relation/finder_methods.rb: 242:in `find_by_attributes'
…1.8/gems/activerecord-3.0.10/lib/active_record/base.rb: 993:in `send'
…1.8/gems/activerecord-3.0.10/lib/active_record/base.rb: 993:in `method_missing_without_create_or_update'
…11110100150/vendor/plugins/create_or_update_by/init.rb: 37:in `method_missing'
…111110100150/app/controllers/application_controller.rb: 79:in `find_site'

Thanks, Enrico