mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 19:13:30 +01:00
handle connection lost/server gone error when starting a transaction
This commit is contained in:
parent
00b448a0c5
commit
f3e0bf540d
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user