Merge "Increase LocalFile lock() timeout and improve error message"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 17 May 2016 09:24:15 +0000 (09:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 17 May 2016 09:24:15 +0000 (09:24 +0000)
includes/filerepo/file/LocalFile.php

index f7275fc..2a15fd7 100644 (file)
@@ -1920,12 +1920,15 @@ class LocalFile extends File {
                        // Also, that would cause contention on INSERT of similarly named rows.
                        $backend = $this->getRepo()->getBackend();
                        $lockPaths = [ $this->getPath() ]; // represents all versions of the file
-                       $status = $backend->lockFiles( $lockPaths, LockManager::LOCK_EX, 5 );
+                       $start = microtime( true );
+                       $status = $backend->lockFiles( $lockPaths, LockManager::LOCK_EX, 10 );
+                       $waited = microtime( true ) - $start;
                        if ( !$status->isGood() ) {
                                if ( $this->lockedOwnTrx ) {
                                        $dbw->rollback( __METHOD__ );
                                }
-                               throw new LocalFileLockError( "Could not acquire lock for '{$this->getName()}.'" );
+                               throw new LocalFileLockError(
+                                       "Could not acquire lock for '{$this->getName()}' ($waited sec)." );
                        }
                        // Release the lock *after* commit to avoid row-level contention
                        $this->locked++;