mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-27 11:06:50 +01:00 
			
		
		
		
	handle MySQL connection lost/server gone when starting a transaction
This commit is contained in:
		| @@ -150,8 +150,17 @@ void SessionHandle::close() | ||||
|  | ||||
| void SessionHandle::startTransaction() | ||||
| { | ||||
| 	if (mysql_autocommit(_pHandle, false) != 0) | ||||
| 		throw TransactionException("Start transaction failed.", _pHandle); | ||||
| 	int rc = mysql_autocommit(_pHandle, false); | ||||
| 	if (rc != 0) | ||||
| 	{ | ||||
| 		// retry if connection lost | ||||
| 		int err = mysql_errno(_pHandle); | ||||
| 		if (err == 2006 /* CR_SERVER_GONE_ERROR */ || err == 2013 /* CR_SERVER_LOST */) | ||||
| 		{ | ||||
| 			rc = mysql_autocommit(_pHandle, false); | ||||
| 		} | ||||
| 	} | ||||
| 	if (rc != 0) throw TransactionException("Start transaction failed.", _pHandle); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Guenter Obiltschnig
					Guenter Obiltschnig