Merge "WikiPage: Avoid locking comment and actor tables in doDeleteArticleReal"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 11 Apr 2018 20:50:29 +0000 (20:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 11 Apr 2018 20:50:29 +0000 (20:50 +0000)
includes/page/WikiPage.php

index f45036c..f3860c6 100644 (file)
@@ -2871,13 +2871,32 @@ class WikiPage implements Page, IDBAccessObject {
                // In the future, we may keep revisions and mark them with
                // the rev_deleted field, which is reserved for this purpose.
 
+               // Lock rows in `revision` and its temp tables, but not any others.
+               // Note array_intersect() preserves keys from the first arg, and we're
+               // assuming $revQuery has `revision` primary and isn't using subtables
+               // for anything we care about.
+               $res = $dbw->select(
+                       array_intersect(
+                               $revQuery['tables'],
+                               [ 'revision', 'revision_comment_temp', 'revision_actor_temp' ]
+                       ),
+                       '1',
+                       [ 'rev_page' => $id ],
+                       __METHOD__,
+                       'FOR UPDATE',
+                       $revQuery['joins']
+               );
+               foreach ( $res as $row ) {
+                       // Fetch all rows in case the DB needs that to properly lock them.
+               }
+
                // Get all of the page revisions
                $res = $dbw->select(
                        $revQuery['tables'],
                        $revQuery['fields'],
                        [ 'rev_page' => $id ],
                        __METHOD__,
-                       'FOR UPDATE',
+                       [],
                        $revQuery['joins']
                );