Database updater: feed SQL files to mysql on stdin
The updater applied each file with `mysql -e "BEGIN; SOURCE <file>; 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.
This commit is contained in:
@@ -422,17 +422,16 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& 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 <file>; 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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user