Log sync db queries in World::Update() loop (#25174)

* Core/Misc: Log sync queries on critical path

* Fix build

* Rename

* Fix warning

* Fix no-pch

* Change WarnAboutSyncQueries() to be header-only

(cherry picked from commit deceb11b5fc52c8036f249d628ccc69ca5d022b3)
This commit is contained in:
Giacomo Pozzoni
2022-01-24 14:58:08 +01:00
committed by Shauren
parent 6d9a084036
commit 736b9ac112
4 changed files with 39 additions and 0 deletions
@@ -34,6 +34,10 @@
#include "Transaction.h"
#include "MySQLWorkaround.h"
#include <mysqld_error.h>
#ifdef TRINITY_DEBUG
#include <sstream>
#include <boost/stacktrace.hpp>
#endif
#define MIN_MYSQL_SERVER_VERSION 50100u
#define MIN_MYSQL_CLIENT_VERSION 50100u
@@ -413,6 +417,15 @@ void DatabaseWorkerPool<T>::Enqueue(SQLOperation* op)
template <class T>
T* DatabaseWorkerPool<T>::GetFreeConnection()
{
#ifdef TRINITY_DEBUG
if (_warnSyncQueries)
{
std::ostringstream ss;
ss << boost::stacktrace::stacktrace();
TC_LOG_WARN("sql.performances", "Sync query at:\n%s", ss.str().c_str());
}
#endif
uint8 i = 0;
auto const num_cons = _connections[IDX_SYNCH].size();
T* connection = nullptr;