Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-29 13:48:23 +0200
committerErich Eckner <git@eckner.net>2018-03-29 13:48:23 +0200
commit37dd4786515d78db928d6bdd7fd844452f0dd0c9 (patch)
treecc7be1436a34d15aa86d5c3b0022c21c1c558d49 /lib
parent792664b9373ded19f242163b3f9cfe16c224d5db (diff)
lib/mysql-functions: mysql_cleanup: remove obsolete files and file_providers partition by partition
Diffstat (limited to 'lib')
-rwxr-xr-xlib/mysql-functions41
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
}