Index: AUTHORS
===================================================================
--- AUTHORS	(revision 18610)
+++ AUTHORS	(working copy)
@@ -269,6 +269,7 @@
 Diane Trout <detrout@earthlink.net> scheme QIF import patch
 Nicolae Turcan <nicturcan@gmail.com> Romanian translation
 Richard -Gilligan- Uschold <uschold@cs.ucf.edu> tax report & txf export
+Tom Van Braeckel <tomvanbraeckel@gmail.com> MySQL timeout reconnect patch
 Matthew Vanecek <mevanecek@yahoo.com> lots of postgres backend work
 Didier Vidal <didier-devel@9online.fr> various G2 fixes.
 Oliver Vollmer <ovo@mx.lihas.de> German account templates SKR03
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,14 @@
 
 	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" );
