Skip to content

Commit

Permalink
Bug #608032: Handle MySQL connection timeouts with reconnect
Browse files Browse the repository at this point in the history
Patch by Tom van Braeckel:

For the full discussion, see the mailing list:
https://lists.gnucash.org/pipermail/gnucash-devel/2010-February/027323.html

Rationale: When we try to open a database transaction, and the database reports
that the "server has gone away", we try to reconnect before failing hard.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18672 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
cstim committed Feb 18, 2010
1 parent 7746357 commit e93496f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/dbi/gnc-backend-dbi.c
Expand Up @@ -1377,6 +1377,14 @@ conn_begin_transaction( /*@ unused @*/ GncSqlConnection* conn )

DEBUG( "BEGIN\n" );
result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" );

/* Handle MySQL connection timeouts with reconnect */
if (result == NULL && dbi_conn_error( dbi_conn->conn, NULL ) == 2006 ) {
DEBUG( "MySQL server has gone away, reconnecting and retrying...\n" );
(void)dbi_conn_connect( dbi_conn->conn );
result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" );
}

status = dbi_result_free( result );
if( status < 0 ) {
PERR( "Error in dbi_result_free() result\n" );
Expand Down

0 comments on commit e93496f

Please sign in to comment.