From 25248a8c35097daa3ef7f900916118b591a1ebe8 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 4 Dec 2017 16:33:24 -0500 Subject: [PATCH] Make sure to close the database connection before forking in verbs This prevents a bug with the postgres driver from breaking the verbs Fixes https://jira.coreos.com/browse/QS-68 --- endpoints/verbs/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) 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()