Change registry code to disconnect from the DB before long I/O operations
This commit is contained in:
parent
23d9bd2b42
commit
d5bbb57481
3 changed files with 26 additions and 7 deletions
|
@ -13,7 +13,7 @@ from util import checksums, changes
|
|||
from util.http import abort, exact_abort
|
||||
from auth.permissions import (ReadRepositoryPermission,
|
||||
ModifyRepositoryPermission)
|
||||
from data import model
|
||||
from data import model, database
|
||||
from util import gzipstream
|
||||
|
||||
|
||||
|
@ -152,8 +152,9 @@ def get_image_layer(namespace, repository, image_id, headers):
|
|||
|
||||
profile.debug('Streaming layer data')
|
||||
|
||||
# TODO: DATABASE: We should disconnect from the database here, so that
|
||||
# we're not holding the DB handle during this long download.
|
||||
# Close the database handle here for this process before we send the long download.
|
||||
database.close_db_filter(None)
|
||||
|
||||
return Response(store.stream_read(repo_image.storage.locations, path), headers=headers)
|
||||
except (IOError, AttributeError):
|
||||
profile.debug('Image not found')
|
||||
|
@ -215,11 +216,9 @@ def put_image_layer(namespace, repository, image_id):
|
|||
h, sum_hndlr = checksums.simple_checksum_handler(json_data)
|
||||
sr.add_handler(sum_hndlr)
|
||||
|
||||
# TODO: DATABASE: We should disconnect from the database here and reconnect AFTER, so that
|
||||
# we're not holding the DB handle during this long upload.
|
||||
|
||||
# Stream write the data to storage.
|
||||
store.stream_write(repo_image.storage.locations, layer_path, sr)
|
||||
with database.CloseForLongOperation(app.config):
|
||||
store.stream_write(repo_image.storage.locations, layer_path, sr)
|
||||
|
||||
# Append the computed checksum.
|
||||
csums = []
|
||||
|
|
Reference in a new issue