Reduce updateLinksTimestamp() DB contention
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 12 Nov 2015 20:46:45 +0000 (12:46 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 17 Nov 2015 02:36:37 +0000 (02:36 +0000)
Do the LinksUpdateComplete hook updates in a separate
transaction as they may do slow SELECTs and updates.

A large amount of DBPerformance warnings were triggered
by such cases.

Bug: T95501
Change-Id: Ie4e6b7f6aefc21bafba270282c55571ff5385fe0

includes/deferred/LinksUpdate.php

index dbfdab0..a6290ed 100644 (file)
@@ -145,7 +145,11 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate {
        public function doUpdate() {
                Hooks::run( 'LinksUpdate', array( &$this ) );
                $this->doIncrementalUpdate();
-               Hooks::run( 'LinksUpdateComplete', array( &$this ) );
+
+               $that = $this;
+               $this->mDb->onTransactionIdle( function() use ( $that ) {
+                       Hooks::run( 'LinksUpdateComplete', array( &$that ) );
+               } );
        }
 
        protected function doIncrementalUpdate() {