diff options
author | jackpoz <giacomopoz@gmail.com> | 2015-02-03 22:16:41 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2015-02-04 19:42:39 +0100 |
commit | d4db0c15c7e59f7139619720be3c26a48e6ff259 (patch) | |
tree | 891891bacff604a770d332778428a52b463cd671 /src/server/shared/Database/Transaction.cpp | |
parent | 8b50c142cbf72a51141e7b25c2e0111af6315ce2 (diff) |
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.
Diffstat (limited to 'src/server/shared/Database/Transaction.cpp')
-rw-r--r-- | src/server/shared/Database/Transaction.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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 <mysqld_error.h> //- 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; } |