From 473ab6e80e28ac86444a256b4928d74e57f193ba Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 7 Jun 2016 05:15:42 -0700 Subject: [PATCH] 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 --- includes/deferred/LinksUpdate.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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(); } /** -- 2.20.1