Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2023-05-15 22:22:00 +0200
committerErich Eckner <git@eckner.net>2023-05-15 22:22:00 +0200
commit82f9063ea0b5855603a516def56ce1b41f62909e (patch)
treed04d826f5aa639a7caad166bf116dabee30a9809
parent1e73a512b4e04e3d525afe1a1d6d6f7abdbead87 (diff)
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
-rwxr-xr-xlib/mysql-functions30
1 files changed, 17 insertions, 13 deletions
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