jenkins-bot has submitted this change and it was merged.

Change subject: Defer copyLocalImagelinks() logic to avoid DB contention
......................................................................


Defer copyLocalImagelinks() logic to avoid DB contention

Run the updates in autocommit mode after the main transaction.
Files are already moved at this point, so we are committed to
moving forward.

Bug: T139306
Change-Id: I1392db0a764d6c8d9f98a73004cf2a808f502384
---
M GlobalUsage_body.php
1 file changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GlobalUsage_body.php b/GlobalUsage_body.php
index 7713230..ca3fe1c 100644
--- a/GlobalUsage_body.php
+++ b/GlobalUsage_body.php
@@ -101,16 +101,16 @@
         *
         * @param $title Title Title of the file to copy entries from.
         */
-       public function copyLocalImagelinks( $title ) {
+       public function copyLocalImagelinks( Title $title ) {
                global $wgContLang;
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select(
+               $res = $this->db->select(
                        array( 'imagelinks', 'page' ),
                        array( 'il_to', 'page_id', 'page_namespace', 
'page_title' ),
                        array( 'il_from = page_id', 'il_to' => 
$title->getDBkey() ),
                        __METHOD__
                );
+
                $insert = array();
                foreach ( $res as $row ) {
                        $insert[] = array(
@@ -122,7 +122,11 @@
                                'gil_to' => $row->il_to,
                        );
                }
-               $this->db->insert( 'globalimagelinks', $insert, __METHOD__, 
array( 'IGNORE' ) );
+
+               $fname = __METHOD__;
+               DeferredUpdates::addCallableUpdate( function () use ( $insert, 
$fname ) {
+                       $this->db->insert( 'globalimagelinks', $insert, $fname, 
array( 'IGNORE' ) );
+               } );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/297334
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1392db0a764d6c8d9f98a73004cf2a808f502384
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GlobalUsage
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to