Skip to content

Commit

Permalink
storage: prevent registry worker crash for large layers (PROJQUAY-760…
Browse files Browse the repository at this point in the history
…3) (quay#3123)


during manifest push, we generate a map of blobs which
are part of the manifest layers. This is done using a
UNION query which can overload the worker if the
number of layers is too large. Instead, run each
query individually to prevent the crash
  • Loading branch information
syed authored Aug 9, 2024
1 parent 3e1f171 commit bb054bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/model/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ def _lookup_repo_storages_by_content_checksum(repo, checksums, model_class):
queries.append(ImageStorage.select(SQL("*")).from_(candidate_subq))

assert queries

# Prevent crash on gunicorn (PROJQUAY-7603)
# If the number of queries is too large, the UNION query
# generated crashes gunicorn, instead run each query
# individually
if len(queries) > 1000:
result = [next(iter(q.execute()), None) for q in queries]
return [r for r in result if r is not None]

return _basequery.reduce_as_tree(queries)


Expand Down

0 comments on commit bb054bf

Please sign in to comment.