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 );
} );
}
*
* @param IDatabase $dbw
* @param integer $pageId
- * @return ScopedCallback|null Returns null on failure
+ * @param string $why One of (job, atomicity)
+ * @return ScopedCallback
* @throws RuntimeException
* @since 1.27
*/
- public static function acquirePageLock( IDatabase $dbw, $pageId ) {
- $scopedLock = $dbw->getScopedLockAndFlush(
- "LinksUpdate:pageid:$pageId",
- __METHOD__,
- 15
- );
+ public static function acquirePageLock( IDatabase $dbw, $pageId, $why = 'atomicity' ) {
+ $key = "LinksUpdate:$why:pageid:$pageId";
+ $scopedLock = $dbw->getScopedLockAndFlush( $key, __METHOD__, 15 );
if ( !$scopedLock ) {
- throw new RuntimeException( "Could not acquire lock on page #$pageId." );
+ throw new RuntimeException( "Could not acquire lock '$key'." );
}
return $scopedLock;
$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();
}
/**
* @param array $cats
*/
function invalidateCategories( $cats ) {
- $this->invalidatePages( NS_CATEGORY, array_keys( $cats ) );
+ PurgeJobUtils::invalidatePages( $this->mDb, NS_CATEGORY, array_keys( $cats ) );
}
/**
* @param array $images
*/
function invalidateImageDescriptions( $images ) {
- $this->invalidatePages( NS_FILE, array_keys( $images ) );
+ PurgeJobUtils::invalidatePages( $this->mDb, NS_FILE, array_keys( $images ) );
}
/**
*/
private function incrTableUpdate( $table, $prefix, $deletions, $insertions ) {
$bSize = RequestContext::getMain()->getConfig()->get( 'UpdateRowsPerQuery' );
+ $factory = wfGetLBFactory();
if ( $table === 'page_props' ) {
$fromField = 'pp_page';
foreach ( $deleteWheres as $deleteWhere ) {
$this->mDb->delete( $table, $deleteWhere, __METHOD__ );
- $this->mDb->commit( __METHOD__, 'flush' );
- wfGetLBFactory()->waitForReplication( [ 'wiki' => $this->mDb->getWikiID() ] );
+ $factory->commitAndWaitForReplication(
+ __METHOD__, $this->ticket, [ 'wiki' => $this->mDb->getWikiID() ]
+ );
}
$insertBatches = array_chunk( $insertions, $bSize );
foreach ( $insertBatches as $insertBatch ) {
$this->mDb->insert( $table, $insertBatch, __METHOD__, 'IGNORE' );
- $this->mDb->commit( __METHOD__, 'flush' );
- wfGetLBFactory()->waitForReplication( [ 'wiki' => $this->mDb->getWikiID() ] );
+ $factory->commitAndWaitForReplication(
+ __METHOD__, $this->ticket, [ 'wiki' => $this->mDb->getWikiID() ]
+ );
}
if ( count( $insertions ) ) {