X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdeferred%2FLinksUpdate.php;h=c6facd9bf8088c16edf2183358749d71e37eb7ae;hp=56979609f202cf2f8d19980dc8defe1e1b78fcb9;hb=89539f2aa1b158fdcc703ad053e2580cb97a6385;hpb=9b4fd6a6c054a8b012ea0d358478f3ee1c392469 diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 56979609f2..c6facd9bf8 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -102,8 +102,6 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { private $db; /** - * Constructor - * * @param Title $title Title of the page we're updating * @param ParserOutput $parserOutput Output from a full parse of this page * @param bool $recursive Queue jobs for recursive updates? @@ -364,21 +362,24 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { private function updateCategoryCounts( array $added, array $deleted ) { global $wgUpdateRowsPerQuery; + if ( !$added && !$deleted ) { + return; + } + + $wikiId = $this->getDB()->getWikiID(); $wp = WikiPage::factory( $this->mTitle ); - $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $lbf = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + // T163801: try to release any row locks to reduce contention + $lbf->commitAndWaitForReplication( __METHOD__, $this->ticket, [ 'wiki' => $wikiId ] ); foreach ( array_chunk( array_keys( $added ), $wgUpdateRowsPerQuery ) as $addBatch ) { $wp->updateCategoryCounts( $addBatch, [], $this->mId ); - $factory->commitAndWaitForReplication( - __METHOD__, $this->ticket, [ 'wiki' => $this->getDB()->getWikiID() ] - ); + $lbf->commitAndWaitForReplication( __METHOD__, $this->ticket, [ 'wiki' => $wikiId ] ); } foreach ( array_chunk( array_keys( $deleted ), $wgUpdateRowsPerQuery ) as $deleteBatch ) { $wp->updateCategoryCounts( [], $deleteBatch, $this->mId ); - $factory->commitAndWaitForReplication( - __METHOD__, $this->ticket, [ 'wiki' => $this->getDB()->getWikiID() ] - ); + $lbf->commitAndWaitForReplication( __METHOD__, $this->ticket, [ 'wiki' => $wikiId ] ); } } @@ -399,7 +400,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { private function incrTableUpdate( $table, $prefix, $deletions, $insertions ) { $services = MediaWikiServices::getInstance(); $bSize = $services->getMainConfig()->get( 'UpdateRowsPerQuery' ); - $factory = $services->getDBLoadBalancerFactory(); + $lbf = $services->getDBLoadBalancerFactory(); if ( $table === 'page_props' ) { $fromField = 'pp_page'; @@ -409,7 +410,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { $deleteWheres = []; // list of WHERE clause arrays for each DB delete() call if ( $table === 'pagelinks' || $table === 'templatelinks' || $table === 'iwlinks' ) { - $baseKey = ( $table === 'iwlinks' ) ? 'iwl_prefix' : "{$prefix}_namespace"; + $baseKey = ( $table === 'iwlinks' ) ? 'iwl_prefix' : "{$prefix}_namespace"; $curBatchSize = 0; $curDeletionBatch = []; @@ -451,7 +452,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { foreach ( $deleteWheres as $deleteWhere ) { $this->getDB()->delete( $table, $deleteWhere, __METHOD__ ); - $factory->commitAndWaitForReplication( + $lbf->commitAndWaitForReplication( __METHOD__, $this->ticket, [ 'wiki' => $this->getDB()->getWikiID() ] ); } @@ -459,7 +460,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { $insertBatches = array_chunk( $insertions, $bSize ); foreach ( $insertBatches as $insertBatch ) { $this->getDB()->insert( $table, $insertBatch, __METHOD__, 'IGNORE' ); - $factory->commitAndWaitForReplication( + $lbf->commitAndWaitForReplication( __METHOD__, $this->ticket, [ 'wiki' => $this->getDB()->getWikiID() ] ); }