From: Aaron Schulz Date: Tue, 17 May 2016 11:19:29 +0000 (-0700) Subject: Limit DELETE in purgeExpiredRestrictions() and use primary key X-Git-Tag: 1.31.0-rc.0~6896^2 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=d58f0155df6b2cec1d8d691d877f19c0dc0a873d;p=lhc%2Fweb%2Fwiklou.git Limit DELETE in purgeExpiredRestrictions() and use primary key This should help reduce contention in some cases. If too many rows are expired, subsequent updates will clear them out. Bug: T135470 Change-Id: Iada496d0db9b00e77037320d7c65124a8c8f68c0 --- diff --git a/includes/Title.php b/includes/Title.php index 25fbce3f57..3a5b62b333 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2971,6 +2971,8 @@ class Title implements LinkTarget { /** * Purge expired restrictions from the page_restrictions table + * + * This will purge no more than $wgUpdateRowsPerQuery page_restrictions rows */ static function purgeExpiredRestrictions() { if ( wfReadOnly() ) { @@ -2981,11 +2983,24 @@ class Title implements LinkTarget { wfGetDB( DB_MASTER ), __METHOD__, function ( IDatabase $dbw, $fname ) { - $dbw->delete( + $config = MediaWikiServices::getInstance()->getMainConfig(); + $ids = $dbw->selectFieldValues( 'page_restrictions', + 'pr_id', [ 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ], - $fname + $fname, + [ 'LIMIT' => $config->get( 'UpdateRowsPerQuery' ) ] // T135470 ); + if ( $ids ) { + $dbw->delete( 'page_restrictions', [ 'pr_id' => $ids ], $fname ); + } + } + ) ); + + DeferredUpdates::addUpdate( new AtomicSectionUpdate( + wfGetDB( DB_MASTER ), + __METHOD__, + function ( IDatabase $dbw, $fname ) { $dbw->delete( 'protected_titles', [ 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ],