New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4 - Long running sql queries are killed #9907

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

Comments

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

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Mar 24, 2013

Member

Yep! This was recently reverted @ 7150a9d

Member

jeremy commented Mar 24, 2013

Yep! This was recently reverted @ 7150a9d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment