mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
fix(Core/Shared/DB): recommit transactions on dead-lock error (#6069)
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "DatabaseWorkerPool.h"
|
||||
#include "DatabaseEnv.h"
|
||||
|
||||
#include <mysqld_error.h>
|
||||
|
||||
#define MIN_MYSQL_SERVER_VERSION 50700u
|
||||
#define MIN_MYSQL_CLIENT_VERSION 50700u
|
||||
|
||||
@@ -318,7 +320,8 @@ template <class T>
|
||||
void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction& transaction)
|
||||
{
|
||||
T* con = GetFreeConnection();
|
||||
if (con->ExecuteTransaction(transaction))
|
||||
int errorCode = con->ExecuteTransaction(transaction);
|
||||
if (!errorCode)
|
||||
{
|
||||
con->Unlock(); // OK, operation succesful
|
||||
return;
|
||||
@@ -326,12 +329,12 @@ void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction& transaction)
|
||||
|
||||
//! Handle MySQL Errno 1213 without extending deadlock to the core itself
|
||||
//! TODO: More elegant way
|
||||
if (con->GetLastError() == 1213)
|
||||
if (errorCode == ER_LOCK_DEADLOCK)
|
||||
{
|
||||
uint8 loopBreaker = 5;
|
||||
for (uint8 i = 0; i < loopBreaker; ++i)
|
||||
{
|
||||
if (con->ExecuteTransaction(transaction))
|
||||
if (!con->ExecuteTransaction(transaction))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user