Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/88761


Change subject: Fixed trx isolation bug that could cause text not to be found
......................................................................

Fixed trx isolation bug that could cause text not to be found

* Also added some logging for when revision text is not found

bug: 55418
Change-Id: I0993e8f49d36771cc526fd4afef67455209b8e3a
---
M includes/Revision.php
1 file changed, 23 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/88761/1

diff --git a/includes/Revision.php b/includes/Revision.php
index c09af74..305c8ff 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -61,6 +61,11 @@
         */
        protected $mContentHandler;
 
+       /**
+        * @var int
+        */
+       protected $mQueryFlags = 0;
+
        // Revision deletion constants
        const DELETED_TEXT = 1;
        const DELETED_COMMENT = 2;
@@ -297,6 +302,9 @@
                                $dbw = wfGetDB( DB_MASTER );
                                $rev = self::loadFromConds( $dbw, $conditions, 
$flags );
                        }
+               }
+               if ( $rev ) {
+                       $rev->mQueryFlags = $flags;
                }
                return $rev;
        }
@@ -1477,20 +1485,30 @@
                        $dbr = wfGetDB( DB_SLAVE );
                        $row = $dbr->selectRow( 'text',
                                array( 'old_text', 'old_flags' ),
-                               array( 'old_id' => $this->getTextId() ),
+                               array( 'old_id' => $textId ),
                                __METHOD__ );
                }
 
-               if ( !$row && wfGetLB()->getServerCount() > 1 ) {
-                       // Possible slave lag!
+               // Fallback to the master in case of slave lag. Also use FOR 
UPDATE if it was
+               // used to fetch this revision to avoid missing the row due to 
REPEATABLE-READ.
+               $forUpdate = ( $this->mQueryFlags & self::READ_LOCKING == 
self::READ_LOCKING );
+               if ( !$row && ( $forUpdate || wfGetLB()->getServerCount() > 1 ) 
) {
                        $dbw = wfGetDB( DB_MASTER );
                        $row = $dbw->selectRow( 'text',
                                array( 'old_text', 'old_flags' ),
-                               array( 'old_id' => $this->getTextId() ),
-                               __METHOD__ );
+                               array( 'old_id' => $textId ),
+                               __METHOD__,
+                               $forUpdate ? array( 'FOR UPDATE' ) : array() );
+               }
+
+               if ( !$row ) {
+                       wfDebugLog( 'Revision', "No text row with ID '$textId' 
(revision {$this->getId()})." );
                }
 
                $text = self::getRevisionText( $row );
+               if ( $row && $text === false ) {
+                       wfDebugLog( 'Revision', "No blob for text row '$textId' 
(revision {$this->getId()})." );
+               }
 
                # No negative caching -- negative hits on text rows may be due 
to corrupted slave servers
                if ( $wgRevisionCacheExpiry && $text !== false ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0993e8f49d36771cc526fd4afef67455209b8e3a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

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

Reply via email to