Merge "Use regular slaves for user contribs parent revision queries"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 30 Jan 2014 19:02:27 +0000 (19:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 30 Jan 2014 19:02:27 +0000 (19:02 +0000)
includes/specials/SpecialContributions.php

index 08768b6..b5b67c9 100644 (file)
@@ -605,6 +605,9 @@ class ContribsPager extends ReverseChronologicalPager {
        public $mDb;
        public $preventClickjacking = false;
 
+       /** @var DatabaseBase */
+       public $mDbSecondary;
+
        /**
         * @var array
         */
@@ -641,6 +644,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' );
        }
 
@@ -860,7 +867,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 );
        }