From 82f9063ea0b5855603a516def56ce1b41f62909e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 15 May 2023 22:22:00 +0200 Subject: lib/mysql-functions: make mysql_determine_majority_build_slave_architecture_id more robust * when there are no logs, it would return empty and break the next sql syntactically * give -1 instead, this should not match anything --- lib/mysql-functions | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/mysql-functions b/lib/mysql-functions index c27babc..54de45e 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -1755,20 +1755,24 @@ mysql_query_ordering_correct() { # active build slaves mysql_determine_majority_build_slave_architecture_id() { { - printf 'SELECT' - printf ' COUNT(DISTINCT `ssh_log`.`id`) AS `count`,' - printf '`architectures`.`id`' - printf ' FROM `ssh_log`' - printf ' JOIN `architectures`' - printf ' ON `ssh_log`.`parameters`=CONCAT(`architectures`.`name`," ")' - printf ' WHERE `action`="get-assignment"' - printf ' AND `ssh_log`.`date`>ADDTIME(NOW(),"-1 00:00:00")' - printf ' GROUP BY `ssh_log`.`parameters`' - printf ' ORDER BY `count` DESC' - printf ' LIMIT 1' + { + printf 'SELECT' + printf ' COUNT(DISTINCT `ssh_log`.`id`) AS `count`,' + printf '`architectures`.`id`' + printf ' FROM `ssh_log`' + printf ' JOIN `architectures`' + printf ' ON `ssh_log`.`parameters`=CONCAT(`architectures`.`name`," ")' + printf ' WHERE `action`="get-assignment"' + printf ' AND `ssh_log`.`date`>ADDTIME(NOW(),"-1 00:00:00")' + printf ' GROUP BY `ssh_log`.`parameters`' + printf ' ORDER BY `count` DESC' + printf ' LIMIT 1' + } | \ + mysql_run_query | \ + cut -f2 + echo '-1' } | \ - mysql_run_query | \ - cut -f2 + head -n1 } # mysql_query_delete_packages $package_sources_condition $repositories_condition -- cgit v1.2.3-54-g00ecf