[Catalyst] MySQL server has gone away

Oleg Pronin syber.rus at gmail.com
Thu Apr 26 23:29:03 GMT 2007


One can say that it is a very rare situation. I can tell you that in
production environment (about 1.000.000 hits per day) it happens every day
several times. Some users just see an error, some lost their data. This is
just not always visible to you.

2007/4/27, Oleg Pronin <syber.rus at gmail.com>:
>
> No. SQL query may produce various errors. Imagine that you got an ordinary
> SQL syntax error (you dont know that) and then you want to check $dbh->pi=
ng
> in order to know was there disconnect or not. But between this short mome=
nts
> database connection was lost. And you will think that it was disconnect
> while it was sql error. I can give you more similar "race condition"
> examples. The problem is that between any ping checks and sql queries
> anything can happen.
> Only evaling prepare, execute, etc. and parsing results can give you true
> answer.
>
>
> 2007/4/26, Wade.Stuart at fallon.com <Wade.Stuart at fallon.com>:
> >
> >
> >
> >
> >
> >
> >
> > "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/
> >
> >
> > _______________________________________________
> > 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/
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070427/bfef8=
700/attachment.htm


More information about the Catalyst mailing list