jenkins-bot has submitted this change and it was merged. Change subject: Cut down on deadlocks in invalidatePages() ......................................................................
Cut down on deadlocks in invalidatePages() Bug: T94992 Change-Id: I70f9d931b624e46ccc19f890d61de8d11326e686 --- M includes/deferred/SqlDataUpdate.php 1 file changed, 33 insertions(+), 32 deletions(-) Approvals: Anomie: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/deferred/SqlDataUpdate.php b/includes/deferred/SqlDataUpdate.php index 5823b2e..49164e3 100644 --- a/includes/deferred/SqlDataUpdate.php +++ b/includes/deferred/SqlDataUpdate.php @@ -111,39 +111,40 @@ return; } - /** - * Determine which pages need to be updated - * This is necessary to prevent the job queue from smashing the DB with - * large numbers of concurrent invalidations of the same page - */ - $now = $this->mDb->timestamp(); - $ids = array(); - $res = $this->mDb->select( 'page', array( 'page_id' ), - array( - 'page_namespace' => $namespace, - 'page_title' => $dbkeys, - 'page_touched < ' . $this->mDb->addQuotes( $now ) - ), __METHOD__ - ); + $dbw = $this->mDb; + $dbw->onTransactionPreCommitOrIdle( function() use ( $dbw, $namespace, $dbkeys ) { + /** + * Determine which pages need to be updated + * This is necessary to prevent the job queue from smashing the DB with + * large numbers of concurrent invalidations of the same page + */ + $now = $dbw->timestamp(); + $ids = $dbw->selectFieldValues( 'page', + 'page_id', + array( + 'page_namespace' => $namespace, + 'page_title' => $dbkeys, + 'page_touched < ' . $dbw->addQuotes( $now ) + ), + __METHOD__ + ); - foreach ( $res as $row ) { - $ids[] = $row->page_id; - } + if ( $ids === array() ) { + return; + } - if ( $ids === array() ) { - return; - } - - /** - * Do the update - * We still need the page_touched condition, in case the row has changed since - * the non-locking select above. - */ - $this->mDb->update( 'page', array( 'page_touched' => $now ), - array( - 'page_id' => $ids, - 'page_touched < ' . $this->mDb->addQuotes( $now ) - ), __METHOD__ - ); + /** + * Do the update + * We still need the page_touched condition, in case the row has changed since + * the non-locking select above. + */ + $dbw->update( 'page', + array( 'page_touched' => $now ), + array( + 'page_id' => $ids, + 'page_touched < ' . $dbw->addQuotes( $now ) + ), __METHOD__ + ); + } ); } } -- To view, visit https://gerrit.wikimedia.org/r/201729 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I70f9d931b624e46ccc19f890d61de8d11326e686 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits