Index: AUTHORS
===================================================================
--- AUTHORS	(revision 18610)
+++ AUTHORS	(working copy)
@@ -113,6 +113,7 @@
 Terry Boldt <tboldt@attglobal.net> financial calculator and expression parser
 Forest Bond <forest@alittletooquiet.net> Budget report improvements
 Richard Braakman <dark@xs4all.nl> xml version configure patch
+Tom Van Braeckel <tomvanbraeckel@gmail.com> MySQL timeout reconnect patch
 Simon Britnell <simon.britnell@peace.com> patch to RPM spec
 Christopher B. Browne <cbbrowne@hex.net> for perl, lots of scheme and documentation updates
 Nathan Buchanan <nbinont@yahoo.ca> packaging Windows binaries for release
Index: src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- src/backend/dbi/gnc-backend-dbi.c	(revision 18610)
+++ src/backend/dbi/gnc-backend-dbi.c	(working copy)
@@ -1377,6 +1377,18 @@
 
 	DEBUG( "BEGIN\n" );
 	result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" );
+
+	/* Handle MySQL connection timeouts with reconnect */
+	if (result == NULL) {
+		const gchar* msg;
+		(void)dbi_conn_error( dbi_conn->conn, &msg );
+		if( g_str_has_prefix( msg, "2006: MySQL server has gone away" ) ) {
+			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" );
