Use AutoCommitUpdate in LinksUpdate::doUpdate
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 2 May 2018 00:22:33 +0000 (17:22 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 3 May 2018 23:47:17 +0000 (23:47 +0000)
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

index 8913642..4ddd151 100644 (file)
@@ -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__
-               );
+                       }
+               ) );
        }
 
        /**