From fb7b637660638ad3329bc8a417ba12df632ff1f0 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 16 May 2016 01:26:55 -0400 Subject: [PATCH] Call $job->teardown() even if Job throws an exception. teardown() callbacks are primarily used to reset session after job is done. It seems important to do this, even if exception is thrown by job. Change-Id: I0bd449414527321b0ed9063cea268dea5b0766c4 --- includes/jobqueue/JobRunner.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index a2f55b9e04..1350958b78 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -268,13 +268,19 @@ class JobRunner implements LoggerAwareInterface { DeferredUpdates::doUpdates(); $this->commitMasterChanges( $job ); - $job->teardown(); } catch ( Exception $e ) { MWExceptionHandler::rollbackMasterChangesAndLog( $e ); $status = false; $error = get_class( $e ) . ': ' . $e->getMessage(); MWExceptionHandler::logException( $e ); } + // Always attempt to call teardown() even if Job throws exception. + try { + $job->teardown(); + } catch ( Exception $e ) { + MWExceptionHandler::logException( $e ); + } + // Commit all outstanding connections that are in a transaction // to get a fresh repeatable read snapshot on every connection. // Note that jobs are still responsible for handling slave lag. -- 2.20.1