diff options
author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2022-09-11 18:45:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-11 18:45:14 +0200 |
commit | de4920de81a495ed8d6b04cf68f3912c74921f48 (patch) | |
tree | 0bf2a2005cf0526fdf8e74bc10e293d4b806922a | |
parent | fea9de5b1707a268e8a3131b5707aa908866257c (diff) |
Core/World: Include more details about MaxCoreStuckTime asserts (#28188)
* Core/World: Include more details about MaxCoreStuckTime asserts
Include more details about MaxCoreStuckTime asserts that might help find why FreezeDetector gets triggered with idle MapThreads
* Codestyle fix
-rw-r--r-- | src/server/worldserver/Main.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 1f270b3abcb..69b226a319a 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -475,6 +475,11 @@ void WorldUpdateLoop() uint32 realCurrTime = 0; uint32 realPrevTime = getMSTime(); + uint32 maxCoreStuckTime = uint32(sConfigMgr->GetIntDefault("MaxCoreStuckTime", 60)) * 1000; + uint32 halfMaxCoreStuckTime = maxCoreStuckTime / 2; + if (!halfMaxCoreStuckTime) + halfMaxCoreStuckTime = std::numeric_limits<uint32>::max(); + LoginDatabase.WarnAboutSyncQueries(true); CharacterDatabase.WarnAboutSyncQueries(true); WorldDatabase.WarnAboutSyncQueries(true); @@ -488,8 +493,11 @@ void WorldUpdateLoop() uint32 diff = getMSTimeDiff(realPrevTime, realCurrTime); if (diff < minUpdateDiff) { + uint32 sleepTime = minUpdateDiff - diff; + if (sleepTime >= halfMaxCoreStuckTime) + TC_LOG_ERROR("server.worldserver", "WorldUpdateLoop() waiting for %u ms with MaxCoreStuckTime set to %u ms", sleepTime, maxCoreStuckTime); // sleep until enough time passes that we can update all timers - std::this_thread::sleep_for(Milliseconds(minUpdateDiff - diff)); + std::this_thread::sleep_for(Milliseconds(sleepTime)); continue; } @@ -531,10 +539,14 @@ void FreezeDetector::Handler(std::weak_ptr<FreezeDetector> freezeDetectorRef, bo freezeDetector->_worldLoopCounter = worldLoopCounter; } // possible freeze - else if (getMSTimeDiff(freezeDetector->_lastChangeMsTime, curtime) > freezeDetector->_maxCoreStuckTimeInMs) + else { - TC_LOG_ERROR("server.worldserver", "World Thread hangs, kicking out server!"); - ABORT(); + uint32 msTimeDiff = getMSTimeDiff(freezeDetector->_lastChangeMsTime, curtime); + if (msTimeDiff > freezeDetector->_maxCoreStuckTimeInMs) + { + TC_LOG_ERROR("server.worldserver", "World Thread hangs for %u ms, forcing a crash!", msTimeDiff); + ABORT_MSG("World Thread hangs for %u ms, forcing a crash!", msTimeDiff); + } } freezeDetector->_timer.expires_from_now(boost::posix_time::seconds(1)); |