Use regular slaves for user contribs parent revision queries
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 15 Jan 2014 04:14:17 +0000 (20:14 -0800)
committerKrinkle <krinklemail@gmail.com>
Thu, 16 Jan 2014 07:41:33 +0000 (07:41 +0000)
Follows-up I65d8eb14c7ea1, I790f5b303fa2.

Bug: 59987
Change-Id: I2265dc81835ccef5d74a043cb85400140b4160c2

includes/specials/SpecialContributions.php

index 6b56c2f..1e79a11 100644 (file)
@@ -601,6 +601,9 @@ class ContribsPager extends ReverseChronologicalPager {
        public $mDb;
        public $preventClickjacking = false;
 
+       /** @var DatabaseBase */
+       public $mDbSecondary;
+
        /**
         * @var array
         */
@@ -637,6 +640,10 @@ class ContribsPager extends ReverseChronologicalPager {
                $month = isset( $options['month'] ) ? $options['month'] : false;
                $this->getDateCond( $year, $month );
 
+               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // with extra user based indexes or partioning by user. The additional metadata
+               // queries should use a regular slave since the lookup pattern is not all by user.
+               $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random slave
                $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
        }
 
@@ -856,7 +863,7 @@ class ContribsPager extends ReverseChronologicalPager {
                                $batch->add( $row->page_namespace, $row->page_title );
                        }
                }
-               $this->mParentLens = Revision::getParentLengths( $this->getDatabase(), $revIds );
+               $this->mParentLens = Revision::getParentLengths( $this->mDbSecondary, $revIds );
                $batch->execute();
                $this->mResult->seek( 0 );
        }