mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
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
This commit is contained in:
@@ -33,6 +33,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
|
||||
@@ -412,6 +416,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;
|
||||
|
||||
@@ -206,6 +206,13 @@ class DatabaseWorkerPool
|
||||
//! Keeps all our MySQL connections alive, prevent the server from disconnecting us.
|
||||
void KeepAlive();
|
||||
|
||||
void WarnAboutSyncQueries([[maybe_unused]] bool warn)
|
||||
{
|
||||
#ifdef TRINITY_DEBUG
|
||||
_warnSyncQueries = warn;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 OpenConnections(InternalIndex type, uint8 numConnections);
|
||||
|
||||
@@ -225,6 +232,9 @@ class DatabaseWorkerPool
|
||||
std::unique_ptr<MySQLConnectionInfo> _connectionInfo;
|
||||
std::vector<uint8> _preparedStatementSize;
|
||||
uint8 _async_threads, _synch_threads;
|
||||
#ifdef TRINITY_DEBUG
|
||||
static inline thread_local bool _warnSyncQueries = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user