Normalize and lower the default DB lag wait timeout
[lhc/web/wiklou.git] / includes / libs / rdbms / lbfactory / LBFactory.php
index 187527e..bc428ec 100644 (file)
@@ -75,6 +75,11 @@ abstract class LBFactory implements ILBFactory {
        /** @var callable[] */
        protected $replicationWaitCallbacks = [];
 
+       /** @var array[] $aliases Map of (table => (dbname, schema, prefix) map) */
+       protected $tableAliases = [];
+       /** @var string[] Map of (index alias => index) */
+       protected $indexAliases = [];
+
        /** @var bool Whether this PHP instance is for a CLI script */
        protected $cliMode;
        /** @var string Agent name for query profiling */
@@ -308,7 +313,7 @@ abstract class LBFactory implements ILBFactory {
                $opts += [
                        'domain' => false,
                        'cluster' => false,
-                       'timeout' => 60,
+                       'timeout' => $this->cliMode ? 60 : 10,
                        'ifWritesSince' => null
                ];
 
@@ -358,7 +363,7 @@ abstract class LBFactory implements ILBFactory {
                $failed = [];
                foreach ( $lbs as $i => $lb ) {
                        if ( $masterPositions[$i] ) {
-                               // The DBMS may not support getMasterPos()
+                               // The RDBMS may not support getMasterPos()
                                if ( !$lb->waitForAll( $masterPositions[$i], $opts['timeout'] ) ) {
                                        $failed[] = $lb->getServerName( $lb->getWriterIndex() );
                                }
@@ -523,6 +528,17 @@ abstract class LBFactory implements ILBFactory {
                if ( $this->trxRoundId !== false ) {
                        $lb->beginMasterChanges( $this->trxRoundId ); // set DBO_TRX
                }
+
+               $lb->setTableAliases( $this->tableAliases );
+               $lb->setIndexAliases( $this->indexAliases );
+       }
+
+       public function setTableAliases( array $aliases ) {
+               $this->tableAliases = $aliases;
+       }
+
+       public function setIndexAliases( array $aliases ) {
+               $this->indexAliases = $aliases;
        }
 
        public function setDomainPrefix( $prefix ) {