[Koha-bugs] [Bug 14600] New: MySQL server has gone away

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jul 24 15:56:00 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14600

            Bug ID: 14600
           Summary: MySQL server has gone away
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Database
          Assignee: gmcharlt at gmail.com
          Reporter: olli-antti.kivilahti at jns.fi
        QA Contact: testopia at bugs.koha-community.org

After introducing the Koha::Object and DBIx features:

We have had serious issues with MySQL/MariaDB losing the DB connection,
throwing just the cryptic "MySQL server has gone away" error, after ~5 minutes
of connection inactivity.
This seriously affects all daemonized Perl-processes we use with C4::Context,
like the SIP2-server and Plack and the Mojolicious REST API.

DBIx-layer of DB handle negotiation works fine detecting a stale connection,
but the new connection generation is delegated to DBI (this is inefficient
duplication).
DBI-layer doesn't detect a stale connection and for us (LXC v1.03, Ubuntu
12/14.04) the "mysql_auto_reconnect"-parameter doesn't work.


Our improvement targets the C4::Context->dbh();

<<SNIP
if ( defined($context->{db_driver}) && $context->{db_driver} eq 'mysql' &&
$context->{"dbh"} ) {
    return $context->{"dbh"};
} elsif ( defined($context->{"dbh"}) && $context->{"dbh"}->ping() ) {
    return $context->{"dbh"};
}
SNAP>>

#This prevents the $dbh->ping() from ever getting called:
if ( defined($context->{db_driver}) && $context->{db_driver} eq 'mysql' &&
$context->{"dbh"} ) {
#because $context->{dbh} is true even if the connection is dead.
#Obviously this relies on the "mysql_auto_reconnect"-parameter which doesn't
#work.

This patch adds a timer to ping every 4 minutes to see if the connection is
still alive, regardless of the DB we use (MySQL/MariaDB vs ...).
Pinging every 4 minutes shouldn't make a performance dent, but makes it
possible for us to operate our SIP2-server without restarting it every 5
minutes.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list