From e43fe2a3e8665978ee6f9631cf71ac885bb62c78 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 29 Jun 2016 17:22:03 -0700 Subject: [PATCH] Use a log group for LocalFile lock errors Bug: T132921 Change-Id: I55cafc9e2fff302e55d40a678bf7e25b4bf24026 --- includes/filerepo/file/LocalFile.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 2c846e51bf..066da60e30 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -21,6 +21,8 @@ * @ingroup FileAbstraction */ +use \MediaWiki\Logger\LoggerFactory; + /** * Bump this number when serialized cache records may be incompatible. */ @@ -1910,6 +1912,7 @@ class LocalFile extends File { */ function lock() { if ( !$this->locked ) { + $logger = LoggerFactory::getInstance( 'LocalFile' ); $dbw = $this->repo->getMasterDB(); if ( !$dbw->trxLevel() ) { $dbw->begin( __METHOD__ ); @@ -1925,12 +1928,17 @@ class LocalFile extends File { if ( $this->lockedOwnTrx ) { $dbw->rollback( __METHOD__ ); } + $logger->warning( "Failed to lock '{file}'", [ 'file' => $this->name ] ); + throw new LocalFileLockError( $status ); } // Release the lock *after* commit to avoid row-level contention $this->locked++; - $dbw->onTransactionIdle( function () use ( $backend, $lockPaths ) { - $backend->unlockFiles( $lockPaths, LockManager::LOCK_EX ); + $dbw->onTransactionIdle( function () use ( $backend, $lockPaths, $logger ) { + $status = $backend->unlockFiles( $lockPaths, LockManager::LOCK_EX ); + if ( !$status->isGood() ) { + $logger->error( "Failed to unlock '{file}'", [ 'file' => $this->name ] ); + } } ); } -- 2.20.1