From c14ddc5c30890fc384f886c80f857520c3e047e7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 8 Sep 2016 02:19:32 -0700 Subject: [PATCH] Make sure the lock in JobRunner::commitMasterChanges() releases Used a ScopedCallback in case of exception to avoid queue backup Change-Id: I58a5f152a54ed9a0d5544014788792bd62afbf4a --- includes/jobqueue/JobRunner.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 7a6b5fc138..570d6dbd32 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -537,6 +537,10 @@ class JobRunner implements LoggerAwareInterface { // This will trigger a rollback in the main loop throw new DBError( $dbwSerial, "Timed out waiting on commit queue." ); } + $unlocker = new ScopedCallback( function () use ( $dbwSerial ) { + $dbwSerial->unlock( 'jobrunner-serial-commit', __METHOD__ ); + } ); + // Wait for the replica DBs to catch up $pos = $lb->getMasterPos(); if ( $pos ) { @@ -545,8 +549,6 @@ class JobRunner implements LoggerAwareInterface { // Actually commit the DB master changes $lbFactory->commitMasterChanges( $fnameTrxOwner ); - - // Release the lock - $dbwSerial->unlock( 'jobrunner-serial-commit', __METHOD__ ); + ScopedCallback::consume( $unlocker ); } } -- 2.20.1