X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2Flbfactory%2FLBFactory.php;h=e47e75e1781f90d074d18084714939e6a9698984;hb=2fd62f5dc9941cc269d6c4faa9a8fbe11975d479;hp=130a097c78b1f903aba34550ed34e6247b7ac588;hpb=6d7677df1f6dcac08fe565235032dffab6bbfaee;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 130a097c78..e47e75e178 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -38,23 +38,24 @@ use LogicException; */ abstract class LBFactory implements ILBFactory { /** @var ChronologyProtector */ - protected $chronProt; + private $chronProt; /** @var object|string Class name or object With profileIn/profileOut methods */ - protected $profiler; + private $profiler; /** @var TransactionProfiler */ - protected $trxProfiler; + private $trxProfiler; /** @var LoggerInterface */ - protected $replLogger; + private $replLogger; /** @var LoggerInterface */ - protected $connLogger; + private $connLogger; /** @var LoggerInterface */ - protected $queryLogger; + private $queryLogger; /** @var LoggerInterface */ - protected $perfLogger; + private $perfLogger; /** @var callable Error logger */ - protected $errorLogger; + private $errorLogger; /** @var callable Deprecation logger */ - protected $deprecationLogger; + private $deprecationLogger; + /** @var BagOStuff */ protected $srvCache; /** @var BagOStuff */ @@ -64,33 +65,36 @@ abstract class LBFactory implements ILBFactory { /** @var DatabaseDomain Local domain */ protected $localDomain; + /** @var string Local hostname of the app server */ - protected $hostname; + private $hostname; /** @var array Web request information about the client */ - protected $requestInfo; - - /** @var mixed */ - protected $ticket; - /** @var string|bool String if a requested DBO_TRX transaction round is active */ - protected $trxRoundId = false; - /** @var string|bool Reason all LBs are read-only or false if not */ - protected $readOnlyReason = false; - /** @var callable[] */ - protected $replicationWaitCallbacks = []; + private $requestInfo; + /** @var bool Whether this PHP instance is for a CLI script */ + private $cliMode; + /** @var string Agent name for query profiling */ + private $agent; /** @var array[] $aliases Map of (table => (dbname, schema, prefix) map) */ - protected $tableAliases = []; + private $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 */ - protected $agent; + private $indexAliases = []; + /** @var callable[] */ + private $replicationWaitCallbacks = []; + /** @var mixed */ + private $ticket; + /** @var string|bool String if a requested DBO_TRX transaction round is active */ + private $trxRoundId = false; /** @var string One of the ROUND_* class constants */ private $trxRoundStage = self::ROUND_CURSORY; + /** @var string|bool Reason all LBs are read-only or false if not */ + protected $readOnlyReason = false; + + /** @var string|null */ + private $defaultGroup = null; + const ROUND_CURSORY = 'cursory'; const ROUND_BEGINNING = 'within-begin'; const ROUND_COMMITTING = 'within-commit'; @@ -138,6 +142,7 @@ abstract class LBFactory implements ILBFactory { $this->cliMode = $conf['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ); $this->hostname = $conf['hostname'] ?? gethostname(); $this->agent = $conf['agent'] ?? ''; + $this->defaultGroup = $conf['defaultGroup'] ?? null; $this->ticket = mt_rand(); } @@ -147,6 +152,14 @@ abstract class LBFactory implements ILBFactory { $this->forEachLBCallMethod( 'disable' ); } + public function getLocalDomainID() { + return $this->localDomain->getId(); + } + + public function resolveDomainID( $domain ) { + return ( $domain !== false ) ? (string)$domain : $this->getLocalDomainID(); + } + public function shutdown( $mode = self::SHUTDOWN_CHRONPROT_SYNC, callable $workCallback = null, @@ -505,6 +518,10 @@ abstract class LBFactory implements ILBFactory { // Request opted out of using position wait logic. This is useful for requests // done by the job queue or background ETL that do not have a meaningful session. $this->chronProt->setWaitEnabled( false ); + } elseif ( $this->memStash instanceof EmptyBagOStuff ) { + // No where to store any DB positions and wait for them to appear + $this->chronProt->setEnabled( false ); + $this->replLogger->info( 'Cannot use ChronologyProtector with EmptyBagOStuff.' ); } $this->replLogger->debug( __METHOD__ . ': using request info ' . @@ -575,6 +592,7 @@ abstract class LBFactory implements ILBFactory { 'hostname' => $this->hostname, 'cliMode' => $this->cliMode, 'agent' => $this->agent, + 'defaultGroup' => $this->defaultGroup, 'chronologyCallback' => function ( ILoadBalancer $lb ) { // Defer ChronologyProtector construction in case setRequestInfo() ends up // being called later (but before the first connection attempt) (T192611)