Bug #608032: Handle MySQL connection timeouts with reconnect

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
This commit is contained in:
Christian Stimming 2010-02-18 05:28:22 +00:00
parent 7746357490
commit e93496f04d

View File

@ -1377,6 +1377,14 @@ conn_begin_transaction( /*@ unused @*/ GncSqlConnection* conn )
DEBUG( "BEGIN\n" ); DEBUG( "BEGIN\n" );
result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" ); 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 ); status = dbi_result_free( result );
if( status < 0 ) { if( status < 0 ) {
PERR( "Error in dbi_result_free() result\n" ); PERR( "Error in dbi_result_free() result\n" );