1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00

db: remove transaction from empty layer upload (PROJQUAY-1946) (#775)

Decouples blob upload and db row creation when uploading the empty
layer. This avoids the transaction blocking on non-db/S3 related issues.
This commit is contained in:
Kenny Lee Sin Cheong
2021-05-12 10:59:57 -04:00
committed by GitHub
parent 86d150a204
commit 8591caf037

View File

@@ -239,13 +239,14 @@ def get_or_create_shared_blob(digest, byte_data, storage):
preferred = storage.preferred_locations[0]
location_obj = ImageStorageLocation.get(name=preferred)
with db_transaction():
record = ImageStorage.create(image_size=len(byte_data), content_checksum=digest)
try:
storage.put_content([preferred], storage_model.get_layer_path(record), byte_data)
ImageStoragePlacement.create(storage=record, location=location_obj)
except:
logger.exception("Exception when trying to write special layer %s", digest)
raise
record = ImageStorage.create(image_size=len(byte_data), content_checksum=digest)
return record
try:
storage.put_content([preferred], storage_model.get_layer_path(record), byte_data)
ImageStoragePlacement.create(storage=record, location=location_obj)
except:
logger.exception("Exception when trying to write special layer %s", digest)
record.delete_instance()
raise
return record