From 8781cf6e11033a5abaeef98c43acae5e2434b049 Mon Sep 17 00:00:00 2001 From: Silas Sewell Date: Thu, 3 Dec 2015 11:19:39 -0500 Subject: [PATCH] Increase nginx proxy timeout and close db before storage operation --- conf/server-base.conf | 2 ++ endpoints/v2/blob.py | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/conf/server-base.conf b/conf/server-base.conf index 38906ac91..c502c862a 100644 --- a/conf/server-base.conf +++ b/conf/server-base.conf @@ -64,6 +64,8 @@ location ~ ^/v2 { proxy_request_buffering off; + proxy_read_timeout 300; + proxy_http_version 1.1; proxy_pass http://registry_app_server; diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index 919c4dd16..215732c7c 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -215,19 +215,20 @@ def _finish_upload(namespace, repo_name, upload_obj, expected_digest): if not digest_tools.digests_equal(computed_digest, expected_digest): raise BlobUploadInvalid() - # Move the storage into place, or if this was a re-upload, cancel it final_blob_location = digest_tools.content_path(expected_digest) - if storage.exists({upload_obj.location.name}, final_blob_location): - # It already existed, clean up our upload which served as proof that we had the file - storage.cancel_chunked_upload({upload_obj.location.name}, upload_obj.uuid, - upload_obj.storage_metadata) + # Move the storage into place, or if this was a re-upload, cancel it + with database.CloseForLongOperation(app.config): + if storage.exists({upload_obj.location.name}, final_blob_location): + # It already existed, clean up our upload which served as proof that we had the file + storage.cancel_chunked_upload({upload_obj.location.name}, upload_obj.uuid, + upload_obj.storage_metadata) - else: - # We were the first ones to upload this image (at least to this location) - # Let's copy it into place - storage.complete_chunked_upload({upload_obj.location.name}, upload_obj.uuid, - final_blob_location, upload_obj.storage_metadata) + else: + # We were the first ones to upload this image (at least to this location) + # Let's copy it into place + storage.complete_chunked_upload({upload_obj.location.name}, upload_obj.uuid, + final_blob_location, upload_obj.storage_metadata) # Mark the blob as uploaded. model.blob.store_blob_record_and_temp_link(namespace, repo_name, expected_digest,