From ba7686af99ab2eddfe1ff4b9dbc73760c1d604bf Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 28 Jul 2015 14:34:55 -0400 Subject: [PATCH] Switch back to the read-then-write tag deletion code We changed to this originally to avoid locks --- data/model/tag.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/data/model/tag.py b/data/model/tag.py index 9ac1ea897..199d99704 100644 --- a/data/model/tag.py +++ b/data/model/tag.py @@ -100,12 +100,17 @@ def delete_tag(namespace_name, repository_name, tag_name): def garbage_collect_tags(repo): expired_time = get_epoch_timestamp() - repo.namespace_user.removed_tag_expiration_s - (RepositoryTag - .delete() - .where(RepositoryTag.repository == repo, - ~(RepositoryTag.lifetime_end_ts >> None), - (RepositoryTag.lifetime_end_ts <= expired_time)) - .execute()) + tags_to_delete = list(RepositoryTag + .select(RepositoryTag.id) + .where(RepositoryTag.repository == repo, + ~(RepositoryTag.lifetime_end_ts >> None), + (RepositoryTag.lifetime_end_ts <= expired_time)) + .order_by(RepositoryTag.id)) + if len(tags_to_delete) > 0: + (RepositoryTag + .delete() + .where(RepositoryTag.id << tags_to_delete) + .execute()) def get_tag_image(namespace_name, repository_name, tag_name):