aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2022-09-11 18:45:14 +0200
committerShauren <shauren.trinity@gmail.com>2022-09-29 22:00:08 +0200
commitc80d7696c332cbe45cb0457a75b4f56381317a69 (patch)
tree8831cad73e12662472425a34f161f2a7cc7c9479 /src
parent063d9b156db7c799007554effbd2a1c222407142 (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 (cherry picked from commit de4920de81a495ed8d6b04cf68f3912c74921f48)
Diffstat (limited to 'src')
-rw-r--r--src/server/worldserver/Main.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index 22555f13eec..e226287b58c 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -495,6 +495,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);
@@ -509,8 +514,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;
}
@@ -553,10 +561,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));