Dealing with MySQL disconnects on long running scripts.

Would anyone happen to have some advise for this?

I have a script that runs for months at a time.

On one box, I can do this without issue, on another it disconnects after
a day.

I've been trying various solutions, but since it takes a day to test any
idea, it's been very slow going.

I've tried Issuing a reconnect command, after any ActiveRecord error.
Which didn't help.

I'm using a socket connection, not a hostname

I'm using the compiled version of the gem.

Would anyone happen to have some advise for this?

I have a script that runs for months at a time.

On one box, I can do this without issue, on another it disconnects
after
a day.

I've been trying various solutions, but since it takes a day to test
any
idea, it's been very slow going.

I've tried Issuing a reconnect command, after any ActiveRecord error.
Which didn't help.

Have you tried setting the active record verification_timeout to be
less than whatever timeout has been set on mysql ?

Fred

Been a long time since I tried that, I'll give it another go.

I've seen people complain about it before, but it seems really strange
that there isn't an easy way to force active-record to reconnect after a
disconnect.

From script/console, the following works.
Mymodel.new.save #works
Mymodel.connection.disconnect!
Mymodel.new.save # toss an error.
Mymodel.connection.reconnect!
Mymodel.new.save # works

Yet the equivalent doesn't seem to work in a long running script.

I'll continue poking at it

Thanks for the advise

Frederick Cheung wrote: