Merge "rdbms: use ILoadBalancer in more LBFactory comments"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 10 May 2018 22:26:06 +0000 (22:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 10 May 2018 22:26:06 +0000 (22:26 +0000)
1  2 
includes/libs/rdbms/lbfactory/LBFactory.php

@@@ -95,8 -95,6 +95,8 @@@ abstract class LBFactory implements ILB
        const ROUND_BEGINNING = 'within-begin';
        const ROUND_COMMITTING = 'within-commit';
        const ROUND_ROLLING_BACK = 'within-rollback';
 +      const ROUND_COMMIT_CALLBACKS = 'within-commit-callbacks';
 +      const ROUND_ROLLBACK_CALLBACKS = 'within-rollback-callbacks';
  
        private static $loggerFields =
                [ 'replLogger', 'connLogger', 'queryLogger', 'perfLogger' ];
        /**
         * @see ILBFactory::newMainLB()
         * @param bool $domain
-        * @return LoadBalancer
+        * @return ILoadBalancer
         */
        abstract public function newMainLB( $domain = false );
  
        /**
         * @see ILBFactory::getMainLB()
         * @param bool $domain
-        * @return LoadBalancer
+        * @return ILoadBalancer
         */
        abstract public function getMainLB( $domain = false );
  
        /**
         * @see ILBFactory::newExternalLB()
         * @param string $cluster
-        * @return LoadBalancer
+        * @return ILoadBalancer
         */
        abstract public function newExternalLB( $cluster );
  
        /**
         * @see ILBFactory::getExternalLB()
         * @param string $cluster
-        * @return LoadBalancer
+        * @return ILoadBalancer
         */
        abstract public function getExternalLB( $cluster );
  
                // Actually perform the commit on all master DB connections and revert DBO_TRX
                $this->forEachLBCallMethod( 'commitMasterChanges', [ $fname ] );
                // Run all post-commit callbacks in a separate step
 +              $this->trxRoundStage = self::ROUND_COMMIT_CALLBACKS;
                $e = $this->executePostTransactionCallbacks();
                $this->trxRoundStage = self::ROUND_CURSORY;
                // Throw any last post-commit callback error
                // Actually perform the rollback on all master DB connections and revert DBO_TRX
                $this->forEachLBCallMethod( 'rollbackMasterChanges', [ $fname ] );
                // Run all post-commit callbacks in a separate step
 +              $this->trxRoundStage = self::ROUND_ROLLBACK_CALLBACKS;
                $this->executePostTransactionCallbacks();
                $this->trxRoundStage = self::ROUND_CURSORY;
        }
        }
  
        /**
-        * Base parameters to LoadBalancer::__construct()
+        * Base parameters to ILoadBalancer::__construct()
         * @return array
         */
        final protected function baseLoadBalancerParams() {
 +              if ( $this->trxRoundStage === self::ROUND_COMMIT_CALLBACKS ) {
 +                      $initStage = ILoadBalancer::STAGE_POSTCOMMIT_CALLBACKS;
 +              } elseif ( $this->trxRoundStage === self::ROUND_ROLLBACK_CALLBACKS ) {
 +                      $initStage = ILoadBalancer::STAGE_POSTROLLBACK_CALLBACKS;
 +              } else {
 +                      $initStage = null;
 +              }
 +
                return [
                        'localDomain' => $this->localDomain,
                        'readOnlyReason' => $this->readOnlyReason,
                                // Defer ChronologyProtector construction in case setRequestInfo() ends up
                                // being called later (but before the first connection attempt) (T192611)
                                $this->getChronologyProtector()->initLB( $lb );
 -                      }
 +                      },
 +                      'roundStage' => $initStage
                ];
        }