* (bug 13921) deadlocks mass-deleting media files in categories
authorSam Reed <reedy@users.mediawiki.org>
Mon, 11 Apr 2011 13:07:55 +0000 (13:07 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 11 Apr 2011 13:07:55 +0000 (13:07 +0000)
RELEASE-NOTES
includes/Article.php
includes/filerepo/LocalFile.php

index 2efe905..c05142b 100644 (file)
@@ -239,6 +239,7 @@ PHP if you have not done so prior to upgrading MediaWiki.
   exceeded;"
 * (bug 20468) User::invalidateCache throws 1205: Lock wait timeout exceeded
 * (bug 27639) Transaction timeout when trying to OldLocalFile::upgradeRow()
+* (bug 13921) deadlocks mass-deleting media files in categories
 
  === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
index a52b613..e70b7b8 100644 (file)
@@ -4420,7 +4420,11 @@ class Article {
         */
        public function updateCategoryCounts( $added, $deleted ) {
                $ns = $this->mTitle->getNamespace();
-               $dbw = wfGetDB( DB_MASTER );
+
+               // https://bugzilla.wikimedia.org/show_bug.cgi?id=13921
+               // Create and use a new loadBalancer object, to prevent "1205: Lock wait timeout exceeded;"
+               $lb = wfGetLBFactory()->newMainLB();
+               $dbw = $lb->getConnection( DB_MASTER );
 
                # First make sure the rows exist.  If one of the "deleted" ones didn't
                # exist, we might legitimately not create it, but it's simpler to just
@@ -4472,6 +4476,9 @@ class Article {
                                __METHOD__
                        );
                }
+
+               $lb->commitMasterChanges();
+               $lb->closeAll();
        }
 
        /**
index 1f9184a..de4f758 100644 (file)
@@ -1508,9 +1508,13 @@ class LocalFileDeleteBatch {
        }
 
        function doDBDeletes() {
-               $dbw = $this->file->repo->getMasterDB();
                list( $oldRels, $deleteCurrent ) = $this->getOldRels();
 
+               // https://bugzilla.wikimedia.org/show_bug.cgi?id=13921
+               // Create and use a new loadBalancer object, to prevent "1205: Lock wait timeout exceeded;"
+               $lb = wfGetLBFactory()->newMainLB();
+               $dbw = $lb->getConnection( DB_MASTER );
+
                if ( count( $oldRels ) ) {
                        $dbw->delete( 'oldimage',
                                array(
@@ -1522,6 +1526,9 @@ class LocalFileDeleteBatch {
                if ( $deleteCurrent ) {
                        $dbw->delete( 'image', array( 'img_name' => $this->file->getName() ), __METHOD__ );
                }
+
+               $lb->commitMasterChanges();
+               $lb->closeAll();
        }
 
        /**