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

Change subject: Use onTransactionPreCommitOrIdle in GlobalRenameUserStatus
......................................................................


Use onTransactionPreCommitOrIdle in GlobalRenameUserStatus

Keeps causing deadlocks if a lot of wikis start/finish
at the same time.
As far as I see no one uses the return values or the state
from the DB in the same transaction, so this should be fine.

Bug: T87523
Change-Id: If82b742cc8b19e15a888c70b8fd4272f50656d4f
---
M includes/GlobalRename/GlobalRenameUserStatus.php
1 file changed, 21 insertions(+), 17 deletions(-)

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



diff --git a/includes/GlobalRename/GlobalRenameUserStatus.php 
b/includes/GlobalRename/GlobalRenameUserStatus.php
index 12aa7a7..2d6478b 100644
--- a/includes/GlobalRename/GlobalRenameUserStatus.php
+++ b/includes/GlobalRename/GlobalRenameUserStatus.php
@@ -121,20 +121,22 @@
         *
         * @param string $wiki
         * @param string $status
-        *
-        * @return bool
         */
        public function setStatus( $wiki, $status ) {
                $dbw = $this->getDB( DB_MASTER );
+               $nameWhere = $this->getNameWhereClause( $dbw ); // Can be 
inlined easily once we require more than 5.3
+               $fname = __METHOD__;
 
-               $dbw->update(
-                       'renameuser_status',
-                       array( 'ru_status' => $status ),
-                       array( $this->getNameWhereClause( $dbw ), 'ru_wiki' => 
$wiki ),
-                       __METHOD__
+               $dbw->onTransactionPreCommitOrIdle(
+                       function() use( $dbw, $status, $wiki, $nameWhere, 
$fname ) {
+                               $dbw->update(
+                                       'renameuser_status',
+                                       array( 'ru_status' => $status ),
+                                       array( $nameWhere, 'ru_wiki' => $wiki ),
+                                       $fname
+                               );
+                       }
                );
-
-               return $dbw->affectedRows() === 1;
        }
 
        /**
@@ -166,18 +168,20 @@
         * Mark the process as done for a wiki (=> delete the renameuser_status 
row)
         *
         * @param string $wiki
-        *
-        * @return bool
         */
        public function done( $wiki ) {
                $dbw = $this->getDB( DB_MASTER );
+               $nameWhere = $this->getNameWhereClause( $dbw ); // Can be 
inlined easily once we require more than 5.3
+               $fname = __METHOD__;
 
-               $dbw->delete(
-                       'renameuser_status',
-                       array( $this->getNameWhereClause( $dbw ), 'ru_wiki' => 
$wiki ),
-                       __METHOD__
+               $dbw->onTransactionPreCommitOrIdle(
+                       function() use( $dbw, $wiki, $nameWhere, $fname ) {
+                               $dbw->delete(
+                                       'renameuser_status',
+                                       array( $nameWhere, 'ru_wiki' => $wiki ),
+                                       $fname
+                               );
+                       }
                );
-
-               return $dbw->affectedRows() === 1;
        }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If82b742cc8b19e15a888c70b8fd4272f50656d4f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to