23#include <mysqld_error.h>
29#define DEADLOCK_MAX_RETRY_TIME_MS 60000
60 delete data.element.stmt;
63 free((
void*)(data.element.query));
78 if (errorCode == ER_LOCK_DEADLOCK)
80 std::string threadId = []()
83 std::ostringstream threadIdStream;
84 threadIdStream << std::this_thread::get_id();
85 return threadIdStream.str();
96 TC_LOG_WARN(
"sql.sql",
"Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
99 TC_LOG_ERROR(
"sql.sql",
"Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
127 if (errorCode == ER_LOCK_DEADLOCK)
129 std::string threadId = []()
132 std::ostringstream threadIdStream;
133 threadIdStream << std::this_thread::get_id();
134 return threadIdStream.str();
147 TC_LOG_WARN(
"sql.sql",
"Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
150 TC_LOG_ERROR(
"sql.sql",
"Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
162 if (
m_future.valid() &&
m_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
#define DEADLOCK_MAX_RETRY_TIME_MS
int ExecuteTransaction(std::shared_ptr< TransactionBase > transaction)
std::vector< SQLElementData > m_queries
void AppendPreparedStatement(PreparedStatementBase *statement)
void Append(char const *sql)
TransactionFuture m_future
std::function< void(bool)> m_callback
std::shared_ptr< TransactionBase > m_trans
static std::mutex _deadlockLock
TransactionPromise m_result
PreparedStatementBase * stmt