From 8fedf35b6ca71ce43c38442b60674cf0ed3bc86c Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Fri, 20 Oct 2017 14:47:49 +0200 Subject: [PATCH] Log the original exception in consumer before trying to do anything else. Also commit the db.session before doing build.transition --- module_build_service/scheduler/consumer.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/module_build_service/scheduler/consumer.py b/module_build_service/scheduler/consumer.py index e7add132..f59c0971 100644 --- a/module_build_service/scheduler/consumer.py +++ b/module_build_service/scheduler/consumer.py @@ -238,12 +238,14 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer): try: further_work = handler(conf, session, msg) or [] except Exception as e: - if build: - build.transition(conf, state=models.BUILD_STATES['failed'], - state_reason=str(e)) msg = 'Could not process message handler. See the traceback.' log.exception(msg) - session.commit() + session.rollback() + if build: + session.refresh(build) + build.transition(conf, state=models.BUILD_STATES['failed'], + state_reason=str(e)) + session.commit() log.debug("Done with %s" % idx)