Rails 4 - Long running sql queries are killed #9907

Closed
madmax opened this Issue Mar 24, 2013 · 1 comment

Projects

None yet

2 participants

@madmax
Contributor
madmax commented Mar 24, 2013

Rails 4, mysql2 gem (This problem not exists in rails 3.2)

If we run

ActiveRecord::Base.connection.execute("LONG RUNNING SQL")

We will get

Mysql2::Error: Lost connection to MySQL server during query: ...

It occurs in migrations mostly when we are alerting big tables.

I make some investigation and I think the problem is in class Reaper
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb).
Method remove is called (by reap method) during query and we exception (Mysql2::Error: Lost connection to MySQL server during query)

If we add one of this options:

dead_connection_timeout: 10000000
reaping_frequency: 10000000

to database.yml it will solve problem but rails then will be not able to reconnect to database after connection lost.

@jeremy
Member
jeremy commented Mar 24, 2013

Yep! This was recently reverted @ 7150a9d

@jeremy jeremy closed this Mar 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment