fix(Core/Shared/DB): recommit transactions on dead-lock error (#6069)

This commit is contained in:
UltraNix
2021-06-01 15:36:59 +02:00
committed by GitHub
parent 1889fffbde
commit beb4df9d3e
4 changed files with 20 additions and 12 deletions

View File

@@ -7,6 +7,8 @@
#include "DatabaseEnv.h"
#include "Transaction.h"
#include <mysqld_error.h>
//- Append a raw ad-hoc query to the transaction
void Transaction::Append(const char* sql)
{
@@ -63,14 +65,15 @@ void Transaction::Cleanup()
bool TransactionTask::Execute()
{
if (m_conn->ExecuteTransaction(m_trans))
int errorCode = m_conn->ExecuteTransaction(m_trans);
if (!errorCode)
return true;
if (m_conn->GetLastError() == 1213)
if (errorCode == ER_LOCK_DEADLOCK)
{
uint8 loopBreaker = 5; // Handle MySQL Errno 1213 without extending deadlock to the core itself
for (uint8 i = 0; i < loopBreaker; ++i)
if (m_conn->ExecuteTransaction(m_trans))
if (!m_conn->ExecuteTransaction(m_trans))
return true;
}