From: Aaron Schulz Date: Mon, 15 Jun 2015 23:58:54 +0000 (-0700) Subject: Reduce RC table contention for file deletion X-Git-Tag: 1.31.0-rc.0~11074^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=4a3002063c941e79a48d4903126993a94158e827;p=lhc%2Fweb%2Fwiklou.git Reduce RC table contention for file deletion Bug: T98706 Change-Id: I13f12b93abccb348c7093c77c363a54a65b59142 --- diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index eeadd16451..e9ec7ffa2b 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -995,15 +995,27 @@ class LinksDeletionUpdate extends SqlDataUpdate { # If using cleanup triggers, we can skip some manual deletes if ( !$this->mDb->cleanupTriggers() ) { - # Clean up recentchanges entries... - $this->mDb->delete( 'recentchanges', - array( 'rc_type != ' . RC_LOG, + # Find recentchanges entries to clean up... + $rcIdsForTitle = $this->mDb->selectFieldValues( 'recentchanges', + 'rc_id', + array( + 'rc_type != ' . RC_LOG, 'rc_namespace' => $title->getNamespace(), - 'rc_title' => $title->getDBkey() ), - __METHOD__ ); - $this->mDb->delete( 'recentchanges', + 'rc_title' => $title->getDBkey() + ), + __METHOD__ + ); + $rcIdsForPage = $this->mDb->selectFieldValues( 'recentchanges', + 'rc_id', array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ), - __METHOD__ ); + __METHOD__ + ); + + # T98706: delete PK to avoid lock contention with RC delete log insertions + $rcIds = array_merge( $rcIdsForTitle, $rcIdsForPage ); + if ( $rcIds ) { + $this->mDb->delete( 'recentchanges', array( 'rc_id' => $rcIds ), __METHOD__ ); + } } }