From: Aaron Schulz Date: Tue, 7 Jun 2016 12:15:42 +0000 (-0700) Subject: Avoid contention in updateLinksTimestamp() X-Git-Tag: 1.31.0-rc.0~6689^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=473ab6e80e28ac86444a256b4928d74e57f193ba;p=lhc%2Fweb%2Fwiklou.git Avoid contention in updateLinksTimestamp() Since LinksUpdate::doUpdate() already flushes the transaction, go ahead and flush before other DataUpdates might run (e.g. from RefreshLinksJob). Also release the lock before running the LinksUpdateComplete handlers, as the lock is just to keep LinksUpdate instances from racing with each other. Change-Id: Ied97fa36fbca0203123e9fc966d2e23bfd621c0e --- diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 07b5614424..d4a61faf86 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -155,10 +155,11 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { Hooks::run( 'LinksUpdate', [ &$this ] ); $this->doIncrementalUpdate(); - $this->mDb->onTransactionIdle( function() use ( &$scopedLock ) { + // Commit and release the lock + ScopedCallback::consume( $scopedLock ); + // Run post-commit hooks without DBO_TRX + $this->mDb->onTransactionIdle( function() { Hooks::run( 'LinksUpdateComplete', [ &$this ] ); - // Release the lock *after* the final COMMIT for correctness - ScopedCallback::consume( $scopedLock ); } ); } @@ -243,15 +244,14 @@ class LinksUpdate extends SqlDataUpdate implements EnqueueableDataUpdate { $changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing ); $this->invalidateProperties( $changed ); - # Update the links table freshness for this title - $this->updateLinksTimestamp(); - # Refresh links of all pages including this page # This will be in a separate transaction if ( $this->mRecursive ) { $this->queueRecursiveJobs(); } + # Update the links table freshness for this title + $this->updateLinksTimestamp(); } /**