From 7c3a2e163ae184a7f50b651f63c54fe7f3dcdaca Mon Sep 17 00:00:00 2001 From: jackpoz Date: Tue, 3 Feb 2015 22:16:41 +0100 Subject: Shared/Database: Fix transactions not being recommitted on dead-lock error Fix transactions not being recommitted on dead-lock error (error code 1213) because of calling http://dev.mysql.com/doc/refman/5.0/en/mysql-errno.html after sending the ROLLBACK command. This way the returned error code was related to the ROLLBACK command, not the failed transaction. (cherry picked from commit d4db0c15c7e59f7139619720be3c26a48e6ff259) --- src/server/shared/Database/Transaction.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/server/shared/Database/Transaction.cpp') diff --git a/src/server/shared/Database/Transaction.cpp b/src/server/shared/Database/Transaction.cpp index 3dee865267b..b83b787a106 100644 --- a/src/server/shared/Database/Transaction.cpp +++ b/src/server/shared/Database/Transaction.cpp @@ -17,6 +17,7 @@ #include "DatabaseEnv.h" #include "Transaction.h" +#include //- Append a raw ad-hoc query to the transaction void Transaction::Append(const char* sql) @@ -74,14 +75,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; } -- cgit v1.2.3