diff --git a/endpoints/verbs/__init__.py b/endpoints/verbs/__init__.py index 41aec4671..7dd52bc8e 100644 --- a/endpoints/verbs/__init__.py +++ b/endpoints/verbs/__init__.py @@ -250,6 +250,11 @@ def _repo_verb(namespace, repository, tag, verb, formatter, sign=False, checker= logger.debug('Building and returning derived %s image %s', verb, derived_image.ref) + # Close the database connection before any process forking occurs. This is important because + # the Postgres driver does not react kindly to forking, so we need to make sure it is closed + # so that each process will get its own unique connection. + database.close_db_filter(None) + # Calculate a derived image ID. derived_image_id = hashlib.sha256(repo_image.image_id + ':' + verb).hexdigest()