From: Aaron Schulz Date: Thu, 30 Jun 2016 00:22:03 +0000 (-0700) Subject: Use a log group for LocalFile lock errors X-Git-Tag: 1.31.0-rc.0~6478^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=e43fe2a3e8665978ee6f9631cf71ac885bb62c78;p=lhc%2Fweb%2Fwiklou.git Use a log group for LocalFile lock errors Bug: T132921 Change-Id: I55cafc9e2fff302e55d40a678bf7e25b4bf24026 --- 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 ] ); + } } ); }