From 14da68604b8a96c7eeeb747e221b68a9f7b35405 Mon Sep 17 00:00:00 2001 From: Advocaite Date: Sat, 3 Oct 2026 01:12:18 +0800 Subject: [PATCH] Database updater: feed SQL files to mysql on stdin The updater applied each file with `mysql -e "BEGIN; SOURCE ; COMMIT;"`. That sometimes exited with success without running a single statement of the file: the file was recorded in `updates` as applied, but the MySQL binlog showed no writes from the mysql client (18 of 18 files on one start). Databases then silently missed tables, columns and data ("Table '...' doesn't exist", "Unknown column ..."). The file is now fed on stdin (`mysql ... database < file`), the way applying it by hand always worked. A failing statement still makes mysql exit with an error and stops the server as before. Databases that already missed a file: apply it by hand (every file in sql/custom is safe to run again) or delete its row from the `updates` table so the next start applies it. --- src/server/database/Updater/DBUpdater.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index 7de59cedd2..80e5eedfc7 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -422,17 +422,16 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos #endif - // Execute sql file - args.emplace_back("-e"); - args.emplace_back(Trinity::StringFormat("BEGIN; SOURCE {}; COMMIT;", path.generic_string())); - // Database if (!database.empty()) args.emplace_back(database); - // Invokes a mysql process which doesn't leak credentials to logs + // Execute sql file: fed to mysql on stdin (`mysql ... database < file`). Classic 1.60 fork: `-e "BEGIN; SOURCE ; COMMIT;"` + // sometimes exited with success without running a single statement of the file (seen in the MySQL binlog: only the `updates` + // row was written), so databases silently missed files; feeding the file on stdin never did. A failing statement still makes + // mysql exit with an error. int32 const ret = Trinity::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), std::move(args), - "sql.updates", "", true); + "sql.updates", path.generic_string(), true); if (ret != EXIT_SUCCESS) {