From: umherirrender Date: Mon, 23 May 2016 18:49:21 +0000 (+0200) Subject: Batch updateNotificationTimestamp() UPDATE queries (without wl_id) X-Git-Tag: 1.31.0-rc.0~6853^2 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=14b888c515b02115aa412696af8e3f85e7beade2;p=lhc%2Fweb%2Fwiklou.git Batch updateNotificationTimestamp() UPDATE queries (without wl_id) The new primary key is not usable in production (T130067), so batch the query using the old where condition. Some code ideas from I3dbe1de4cf39499728a2077a71157d4bcc203e44 Bug: T134613 Change-Id: Ic12926a5166f7578a1136c7944d883c2fe1f3b3a --- diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index f0619d69f5..6486955fc4 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -744,15 +744,24 @@ class WatchedItemStore implements StatsdAwareInterface { $fname = __METHOD__; $dbw->onTransactionIdle( function () use ( $dbw, $timestamp, $watchers, $target, $fname ) { - $dbw->update( 'watchlist', - [ /* SET */ - 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) - ], [ /* WHERE */ - 'wl_user' => $watchers, - 'wl_namespace' => $target->getNamespace(), - 'wl_title' => $target->getDBkey(), - ], $fname - ); + global $wgUpdateRowsPerQuery; + + $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery ); + foreach ( $watchersChunks as $watchersChunk ) { + $dbw->update( 'watchlist', + [ /* SET */ + 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) + ], [ /* WHERE - TODO Use wl_id T130067 */ + 'wl_user' => $watchersChunk, + 'wl_namespace' => $target->getNamespace(), + 'wl_title' => $target->getDBkey(), + ], $fname + ); + if ( count( $watchersChunks ) > 1 ) { + $dbw->commit( __METHOD__, 'flush' ); + wfGetLBFactory()->waitForReplication( [ 'wiki' => $dbw->getWikiID() ] ); + } + } $this->uncacheLinkTarget( $target ); } );