From 0070184c30396f71bd30e18af0733fd8b6cd33cf Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 27 Mar 2018 11:23:40 +0200 Subject: lib/mysql-functions: mysql_cleanup now also removes build_slaves.logged_lines --- lib/mysql-functions | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/mysql-functions b/lib/mysql-functions index 8e8217b..aa15192 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -862,19 +862,36 @@ mysql_cleanup() { printf 'SELECT * FROM `build_assignments` ' printf 'WHERE `build_assignments`.`package_source`=`package_sources`.`id`' printf ');\n' - printf 'UPDATE `build_slaves`' + # remove jobs from build slaves that are not on the build-list + if [ "${operator}" = 'DELETE' ]; then + printf 'UPDATE `build_slaves`' + else + printf 'SELECT COUNT(DISTINCT `build_slaves`.`id`) FROM `build_slaves`' + fi mysql_join_build_slaves_binary_packages mysql_join_binary_packages_repositories - printf ' SET `currently_building`=NULL' + if [ "${operator}" = 'DELETE' ]; then + printf ' SET `build_slaves`.`currently_building`=NULL' + fi printf ' WHERE `repositories`.`name`!="build-list";\n' # remove build orders from build slaves which have not connected within 1h if [ "${operator}" = 'DELETE' ]; then - printf 'UPDATE `build_slaves` SET `build_slaves`.`currently_building`=NULL' + printf 'UPDATE `build_slaves`' + printf ' SET `build_slaves`.`currently_building`=NULL' else printf 'SELECT COUNT(*) FROM `build_slaves`' fi printf ' WHERE `build_slaves`.`currently_building` IS NOT NULL' printf ' AND TIMEDIFF(NOW(),`build_slaves`.`last_connection`) > "1:00:00";\n' + # remove `logged_lines` from buildslaves without an assignment + if [ "${operator}" = 'DELETE' ]; then + printf 'UPDATE `build_slaves`' + printf ' SET `build_slaves`.`logged_lines`=NULL' + else + printf 'SELECT COUNT(*) FROM `build_slaves`' + fi + printf ' WHERE `build_slaves`.`currently_building` IS NULL' + printf ' AND `build_slaves`.`logged_lines` IS NOT NULL;\n' # remove obsolete file_providers printf '%s FROM `file_providers`' \ "${operator}" -- cgit v1.2.3-70-g09d2