Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/90385


Change subject: Reduce excess lock contention and chance for failure on rename
......................................................................

Reduce excess lock contention and chance for failure on rename

* DB locks and transactions were getting held up by sometimes slow purges (10+ 
seconds)

Change-Id: I0eead60e8faf5aee6b2ddf59cfdd928f9c8083ff
---
M includes/filerepo/file/LocalFile.php
1 file changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/85/90385/1

diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index 0c34f3e..fe769be 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1507,18 +1507,27 @@
 
                wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
 
-               $this->purgeEverything();
-               foreach ( $archiveNames as $archiveName ) {
-                       $this->purgeOldThumbnails( $archiveName );
-               }
+               // Purge the source and target files...
+               $oldTitleFile = wfLocalFile( $this->title );
+               $newTitleFile = wfLocalFile( $target );
+               // Hack: the lock()/unlock() pair is nested in a transaction so 
the locking is not
+               // tied to BEGIN/COMMIT. To avoid slow purges in the 
transaction, move them outside.
+               $this->getRepo()->getMasterDB()->onTransactionIdle(
+                       function() use ( $oldTitleFile, $newTitleFile, 
$archiveNames ) {
+                               $oldTitleFile->purgeEverything();
+                               foreach ( $archiveNames as $archiveName ) {
+                                       $oldTitleFile->purgeOldThumbnails( 
$archiveName );
+                               }
+                               $newTitleFile->purgeEverything();
+                       }
+               );
+
                if ( $status->isOK() ) {
                        // Now switch the object
                        $this->title = $target;
                        // Force regeneration of the name and hashpath
                        unset( $this->name );
                        unset( $this->hashPath );
-                       // Purge the new image
-                       $this->purgeEverything();
                }
 
                return $status;

-- 
To view, visit https://gerrit.wikimedia.org/r/90385
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0eead60e8faf5aee6b2ddf59cfdd928f9c8083ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to