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
This commit is contained in:
Aaron Schulz 2016-06-07 05:15:42 -07:00
parent 138db9d691
commit 473ab6e80e

View file

@ -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();
}
/**