jhthorsen / mojo-mysql

Mojolicious and Async MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MySQL server has gone away at Database.pm line 78.

d33d opened this issue · comments

Hi all,

I get this (well known) exception: DBD::mysql::st execute failed: MySQL server has gone away at -../Mojo/mysql/Database.pm line 78.

when i catch this exception i disconnect the handle to prevent it from getting cached again (as documentation said) and i submit my query again.

Anyway, is there a more efficient solution? Is there a feature in the module that help to prevent this issue? Thank you.

Wild guess: I think you're storing $mysql->db for a long time, instead of making sure you get a fresh $db handle.

The reason why I'm guessing this is 1) I've only seen that error when working with a stale $dbh. 2) you're not describing when this happens and/or how you manage to reproduce the error message.

You can see all the reasons for MySQL server has gone away error at https://dev.mysql.com/doc/refman/5.0/en/gone-away.html.
The most common reasons are: using a stale handle or connectivity problem.

When you catch this exception you don't have to explicitly disconnect the handle. Mojo::mysql will not cache it.