Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Remove quotes around releases where statement that were breaking the query.

* Ensure $DELETED is always an integer in cleanup script.

* Check manage-db.py return code.

* Version bump.
  • Loading branch information
bhearsum authored May 10, 2019
1 parent 4288562 commit 7365a59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/manage-db.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def extract_active_data(trans, url, dump_location="dump.sql"):
for batched_release_list in batch_generator:
query = ", ".join("'" + names + "'" for names in batched_release_list)
cmd = mysql_data_only_command(host, user, password, db, "releases").split()
cmd.append('--where="releases.name IN ({})"'.format(query))
cmd.append("--where=releases.name IN ({})".format(query))
run(cmd, stdout=dump_file, check=True)

cmd = mysql_data_only_command(host, user, password, db, "releases_history").split()
Expand Down
14 changes: 13 additions & 1 deletion scripts/run-batch-deletes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ while true; do

printf "Deleting..."
# DBURI and MAX_AGE should be in the environment
DELETED=$(python ./manage-db.py -d "$DBURI" cleanup "$MAX_AGE" 2>/dev/null | awk '/Total/ {print $3}')
DELETED=$(python ./manage-db.py -d "$DBURI" cleanup "$MAX_AGE" 2>/dev/null)
if ! [ "$?" -eq "0" ]; then
echo "manage-db.py didn't exit cleanly"
continue
fi
DELETED=$(echo "$DELETED" | awk '/Total/ {print $3}')
ORIG_DELETED=$DELETED
# Sometimes DELETED ends up not being set for some reason, which breaks
# the `expr` expressions below, and gets the script stuck in a loop.
if ! [ "$DELETED" -eq "$DELETED" ] 2>/dev/null; then
DELETED=0
fi
TOTAL=$(expr $TOTAL + $DELETED)
NOW=$(date '+%s')
printf "%d rows removed >>> %d seconds remaining. %d deleted.\n" $DELETED $(expr $TIL - $NOW) $TOTAL

echo "Original value for \$DELETED: $ORIG_DELETED"
if [ $DELETED -eq 0 ]; then
echo "Nothing left to do"
exit 0
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.63
2.64

0 comments on commit 7365a59

Please sign in to comment.