[Catalyst] MySQL server has gone away

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Thu Apr 26 19:43:53 GMT 2007







"Oleg Pronin" <syber.rus at gmail.com> wrote on 04/26/2007 01:29:23 PM:

> Hi all!
>
> Unfortunately, Catalyst::Model::DBI and similar modules are too
> simple to avoid some more rare situations.
> For example, what if $dbh->prepare result is fine but before you
> call $dbh->execute the database will be "gone away"?
>
> I'm creating a DBI wrapper (it will be called DBIx::Safe) that
> handles all disconnections transparently.
> If there is no transaction this module gives you 100% guarantee that
> your query will be executed without disconnection errors.
> In case of transaction it will notify you when you can safely
> restart the transaction (when it fails because of disconnection).
> This is very good feature for DBIx:Class's txn_do method. DBIC could
> restart the transaction (which is coderef) until it is completed
succesfully.
> Together it could be 100% disconnections-safe system.
>
> And I need your help.
> I use $dbh->err to determine that query fails because of disconnection.
> I noticed that posgresql 8.0-8.2 returns errcode "7" when connection
> with database lost.
> Mysql 4.1 returns "2006".
>
> Can you please send me database versions and errcodes for
> disconnects that you know?
> I didn't find it neither in DBD::* nor at database docs website.
>
>

Isn't this what dbi's ping is to be used for?


>
> 2007/4/19, Jon <jon+catalyst at youramigo.com>:
>
> On Thu, 2007-04-19 at 13:54 +0100, Adeola Awoyemi wrote:
> > Hi all,
> >
> > I have problem that when I run my app via fastcgi I get an error
> > where one of my models can't connect to the database with the message
> > "MySQL server has gone away". When I start it using 'script/
> > myapp_server.pl' it works fine.
> >
>
> Would I be correct in guessing that you're using DBI directly, not
> Catalyst::Model::DBI or Catalyst::Model::DBIC::Schema ?
>
> This problem will occur when a process forks after creating a DBI
> connection, since the connection becomes invalid in the child process.
> See the code in Catalyst::Model::DBI for ways to handle this.
>
> Having said that, I can't think how fastcgi would be forking after
> initialising DBI - fastcgi forks first and runs perl later.
>
> Nevertheless I'd still refer you to the automatic connection checking
> and reconnection code in Catalyst::Model::DBI (credit Alex Pavlovic).
>
>
> --
>
> Jon
>
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list