diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/mysql-functions | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions index 095f1cc..418f15b 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -785,6 +785,7 @@ mysql_find_build_assignment_loops() { # clean up left overs from mysql database mysql_cleanup() { local operator + local partition if [ "$#" = '0' ]; then operator='DELETE' elif [ "$#" = '1' ] && [ "x$1" = 'xdry' ]; then @@ -892,23 +893,29 @@ mysql_cleanup() { 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}" - printf ' WHERE NOT EXISTS (' - printf 'SELECT * FROM `binary_packages`' - printf ' WHERE `binary_packages`.`id`=`file_providers`.`package`' - printf ') OR NOT EXISTS (' - printf 'SELECT * FROM `files`' - printf ' WHERE `files`.`id`=`file_providers`.`file`' - printf ');\n' - # remove obsolete files - printf '%s FROM `files`' \ - "${operator}" - printf ' WHERE NOT EXISTS (' - printf 'SELECT * FROM `file_providers`' - printf ' WHERE `files`.`id`=`file_providers`.`file`' - printf ');\n' + for partition in $(seq 0 15); do + # remove obsolete file_providers + printf '%s FROM `file_providers` PARTITION (p%s)' \ + "${operator}" "${partition}" + printf ' WHERE NOT EXISTS (' + printf 'SELECT * FROM `binary_packages`' + printf ' WHERE `binary_packages`.`id`=`file_providers`.`package`' + printf ') OR NOT EXISTS (' + printf 'SELECT * FROM `files` PARTITION (p%s)' \ + "${partition}" + printf ' WHERE `files`.`id`=`file_providers`.`file`' + printf ' AND `files`.`name_hash`=`file_providers`.`name_hash`' + printf ');\n' + # remove obsolete files + printf '%s FROM `files` PARTITION (p%s)' \ + "${operator}" "${partition}" + printf ' WHERE NOT EXISTS (' + printf 'SELECT * FROM `file_providers` PARTITION (p%s)' \ + "${partition}" + printf ' WHERE `files`.`id`=`file_providers`.`file`' + printf ' AND `files`.`name_hash`=`file_providers`.`name_hash`' + printf ');\n' + done } | \ mysql_run_query } |