From 10ee6be4424c8563a75dd046a449e3f87d1bc99f Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 15 Feb 2019 18:13:42 -0500 Subject: [PATCH] Change the security scan update query to only change the indexed row This will mean we try to re-index other similar rows, but that's a no-op on the Clair side, and this update query is extremely heavy and easily interleaving locks --- data/model/image.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/data/model/image.py b/data/model/image.py index 08d6cfa2d..5217b2eb4 100644 --- a/data/model/image.py +++ b/data/model/image.py @@ -463,19 +463,9 @@ def get_image_with_storage_and_parent_base(): def set_secscan_status(image, indexed, version): - query = (Image - .select() - .join(ImageStorage) - .where(Image.docker_image_id == image.docker_image_id, - ImageStorage.uuid == image.storage.uuid)) - - ids_to_update = [row.id for row in query] - if not ids_to_update: - return False - return (Image .update(security_indexed=indexed, security_indexed_engine=version) - .where(Image.id << ids_to_update) + .where(Image.id == image.id) .where((Image.security_indexed_engine != version) | (Image.security_indexed != indexed)) .execute()) != 0