This commit is contained in:
Ovalord committed 2018-02-18 20:55:31 +01:00
commit c9b5bf9534
203 files changed
+1608 -341

No files matched your search

@@ -238,6 +238,7 @@ void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction& transaction)
/// @todo More elegant way
if (errorCode == ER_LOCK_DEADLOCK)
{
//todo: handle multiple sync threads deadlocking in a similar way as async threads
uint8 loopBreaker = 5;
for (uint8 i = 0; i < loopBreaker; ++i)
{
+20 -3
View File
@@ -15,12 +15,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DatabaseEnv.h"
#include "Log.h"
#include "Transaction.h"
#include "MySQLConnection.h"
#include "PreparedStatement.h"
#include "Timer.h"
#include <mysqld_error.h>
#include <sstream>
#include <thread>
std::mutex TransactionTask::_deadlockLock;
#define DEADLOCK_MAX_RETRY_TIME_MS 60000
//- Append a raw ad-hoc query to the transaction
void Transaction::Append(const char* sql)
{
@@ -72,12 +79,22 @@ bool TransactionTask::Execute()
if (errorCode == ER_LOCK_DEADLOCK)
{
std::ostringstream threadIdStream;
threadIdStream << std::this_thread::get_id();
std::string threadId = threadIdStream.str();
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
std::lock_guard<std::mutex> lock(_deadlockLock);
uint8 loopBreaker = 5; // Handle MySQL Errno 1213 without extending deadlock to the core itself
for (uint8 i = 0; i < loopBreaker; ++i)
for (uint32 loopDuration = 0, startMSTime = getMSTime(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
{
if (!m_conn->ExecuteTransaction(m_trans))
return true;
TC_LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: %u ms, Thread Id: %s", loopDuration, threadId.c_str());
}
TC_LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: %s", threadId.c_str());
}
// Clean up now.
+4 -2
View File
@@ -287,10 +287,12 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
}
case LOCATION_DOWNLOAD:
{
const char* filename = base.filename().generic_string().c_str();
const char* workdir = boost::filesystem::current_path().generic_string().c_str();
TC_LOG_ERROR("sql.updates", ">> File \"%s\" is missing, download it from \"https://t.me/trinitycorelegacy\"" \
" Mirror: \"https://github.com/TrinityCoreLegacy/TrinityCore/releases\"" \
" uncompress it and place the file TDB_full_world_(a_variable_name).sql where your worldserver binary is located.", base.filename().generic_string().c_str());
break;
" uncompress it and place the file \"%s\" in the directory \"%s\".", filename, filename, workdir);
break;
}
}
return false;