From 8659c59dcfa7d7b1be83d6048ef477757f38047e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 1 May 2018 17:22:33 -0700 Subject: [PATCH] Use AutoCommitUpdate in LinksUpdate::doUpdate The hook handlers are likely to write to secondary databases, in which case it is better to wrap the callback in its own transaction round. This lowers the chance of pending write warnings happening in runMasterTransactionIdleCallbacks() as well as DBTransactionError exceptions in LBFactory due to recursion during commit. Bug: T191282 Bug: T193668 Change-Id: Ie207ca312888b6bb076f783d41f05b701f70a52e --- includes/deferred/LinksUpdate.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php index 8913642891..4ddd15117b 100644 --- a/includes/deferred/LinksUpdate.php +++ b/includes/deferred/LinksUpdate.php @@ -177,15 +177,16 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate { // Commit and release the lock (if set) ScopedCallback::consume( $scopedLock ); - // Run post-commit hooks without DBO_TRX - $this->getDB()->onTransactionIdle( + // Run post-commit hook handlers without DBO_TRX + DeferredUpdates::addUpdate( new AutoCommitUpdate( + $this->getDB(), + __METHOD__, function () { // Avoid PHP 7.1 warning from passing $this by reference $linksUpdate = $this; Hooks::run( 'LinksUpdateComplete', [ &$linksUpdate, $this->ticket ] ); - }, - __METHOD__ - ); + } + ) ); } /** -- 2.20.1