"MySQL server has gone away"

Hi all,

I am getting the following error in the middle of a long-running process: "Mysql::Error: Lost connection to MySQL server during query:..." When rescued and retried, it throws the next error: "Mysql::Error: MySQL server has gone away"

(1) The query is not long and (2) the process does not last longer than 8 hours (it's < 15 minutes) or idle for a long period.

I've tried: ActiveRecord::Base.allow_concurrency = true, ActiveRecord::Base.verification_timeout = 10, and ActiveRecord::Base.verify_active_connections!

I can use (1) ActiveRecord::Base.connection_pool.with_connection or (2) ActiveRecord::Base.verify_active_connections! to fix it, but...

when future queries search for data that was inserted previously in the process, it is no longer there. It seems like there's something wrapped around everything - tied to the connection - that prevents any writes from really persisting to the database until, I'm assuming, the process is complete.

How do I fix the lost MySQL connections or at least make writes persist to the database mid-process so that when I open a new connection the records will be there?

Any help is appreciated.

Thanks,

Blake

Did you check mysql config on server?