fix(Core/Updater): fail the dry run when a SQL update fails to apply (#26795)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
sudlud
2026-07-26 14:27:03 +02:00
committed by GitHub
parent 70da2f25d6
commit 95eaad9901
6 changed files with 109 additions and 2 deletions

View File

@@ -27,6 +27,7 @@
#include "AuthSocketMgr.h"
#include "Banner.h"
#include "Config.h"
#include "DBUpdater.h"
#include "DatabaseEnv.h"
#include "DatabaseLoader.h"
#include "GitRevision.h"
@@ -149,6 +150,12 @@ int main(int argc, char** argv)
// Stop auth server if dry run
if (sConfigMgr->isDryRun())
{
if (uint32 failed = DBUpdaterUtil::GetFailedUpdateCount())
{
LOG_FATAL("server.authserver", "Dry run completed with {} failed database update(s), terminating.", failed);
return 1;
}
LOG_INFO("server.authserver", "Dry run completed, terminating.");
return 0;
}

View File

@@ -64,6 +64,22 @@ std::string& DBUpdaterUtil::corrected_path()
return path;
}
uint32& DBUpdaterUtil::failed_updates()
{
static uint32 count = 0;
return count;
}
void DBUpdaterUtil::MarkUpdateFailed()
{
++failed_updates();
}
uint32 DBUpdaterUtil::GetFailedUpdateCount()
{
return failed_updates();
}
// Auth Database
template<>
std::string DBUpdater<LoginDatabaseConnection>::GetConfigEntry()
@@ -524,6 +540,10 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
"If you are a developer, please fix your sql query.",
path.generic_string(), pool.GetConnectionInfo()->database);
// Recorded in both modes. A dry run does not throw below, so it keeps attempting the
// remaining files and this count is the only thing left to fail the run on.
DBUpdaterUtil::MarkUpdateFailed();
if (!sConfigMgr->isDryRun())
{
if (uint32 delay = sConfigMgr->GetOption<uint32>("Updates.ExceptionShutdownDelay", 10000))

View File

@@ -60,8 +60,15 @@ public:
static bool CheckExecutable();
// Counts every update file that failed to apply, in any mode. A dry run does not throw
// on a bad file, so it keeps going and a single run reports all of them; whoever ends
// the run must check this and exit non-zero, otherwise CI goes green on a failed import.
static void MarkUpdateFailed();
static uint32 GetFailedUpdateCount();
private:
static std::string& corrected_path();
static uint32& failed_updates();
};
template <class T>

View File

@@ -42,6 +42,7 @@
#include "CreatureGroups.h"
#include "CreatureTextMgr.h"
#include "DBCStores.h"
#include "DBUpdater.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "DynamicVisibility.h"
@@ -1058,6 +1059,13 @@ void World::SetInitialWorldSettings()
if (sConfigMgr->isDryRun())
{
sMapMgr->UnloadAll();
if (uint32 failed = DBUpdaterUtil::GetFailedUpdateCount())
{
LOG_FATAL("server.loading", "AzerothCore Dry Run Completed With {} Failed Database Update(s), Terminating.", failed);
exit(1);
}
LOG_INFO("server.loading", "AzerothCore Dry Run Completed, Terminating.");
exit(0);
}