mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-07 23:38:00 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "Banner.h"
|
||||
#include "Config.h"
|
||||
#include "DBUpdater.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "IoContext.h"
|
||||
@@ -95,6 +96,12 @@ int main(int argc, char** argv)
|
||||
|
||||
LOG_INFO("dbimport", "Halting process...");
|
||||
|
||||
if (uint32 failed = DBUpdaterUtil::GetFailedUpdateCount())
|
||||
{
|
||||
LOG_FATAL("dbimport", "{} update file(s) failed to apply!", failed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user