* - wanCache: WANObjectCache object [optional]
* - hostname: The name of the current server [optional]
* - cliMode: Whether the execution context is a CLI script. [optional]
+ * - maxLag: Try to avoid DB replicas with lag above this many seconds [optional]
* - profiler: Class name or instance with profileIn()/profileOut() methods. [optional]
* - trxProfiler: TransactionProfiler instance. [optional]
* - replLogger: PSR-3 logger instance. [optional]
/** @var string|null */
private $defaultGroup = null;
+ /** @var int|null */
+ protected $maxLag;
+
const ROUND_CURSORY = 'cursory';
const ROUND_BEGINNING = 'within-begin';
const ROUND_COMMITTING = 'within-commit';
? DatabaseDomain::newFromId( $conf['localDomain'] )
: DatabaseDomain::newUnspecified();
+ $this->maxLag = $conf['maxLag'] ?? null;
if ( isset( $conf['readOnlyReason'] ) && is_string( $conf['readOnlyReason'] ) ) {
$this->readOnlyReason = $conf['readOnlyReason'];
}
'hostname' => $this->hostname,
'cliMode' => $this->cliMode,
'agent' => $this->agent,
+ 'maxLag' => $this->maxLag,
'defaultGroup' => $this->defaultGroup,
'chronologyCallback' => function ( ILoadBalancer $lb ) {
// Defer ChronologyProtector construction in case setRequestInfo() ends up
/** @var string */
private $lastSection;
- /** @var int */
- private $maxLag = self::MAX_LAG_DEFAULT;
-
- /** @var int Default 'maxLag' when unspecified */
- const MAX_LAG_DEFAULT = 10;
-
/**
* @see LBFactory::__construct()
*
* storage cluster.
* - masterTemplateOverrides Server configuration map overrides for all master servers.
* - loadMonitorClass Name of the LoadMonitor class to always use.
- * - maxLag Avoid replica DBs with more lag than this many seconds.
* - readOnlyBySection A map of section name to read-only message.
* Missing or false for read/write.
*/
$optional = [ 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
'templateOverridesByCluster', 'templateOverridesBySection', 'masterTemplateOverrides',
- 'readOnlyBySection', 'maxLag', 'loadMonitorClass' ];
+ 'readOnlyBySection', 'loadMonitorClass' ];
foreach ( $required as $key ) {
if ( !isset( $conf[$key] ) ) {
$this->baseLoadBalancerParams(),
[
'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
- 'maxLag' => $this->maxLag,
'loadMonitor' => [ 'class' => $this->loadMonitorClass ],
'readOnlyReason' => $readOnlyReason
]
/** @var string */
private $loadMonitorClass;
- /** @var int */
- private $maxLag;
-
- /** @var int Default 'maxLag' when unspecified */
- const MAX_LAG_DEFAULT = 10;
/**
* @see LBFactory::__construct()
$this->externalClusters = $conf['externalClusters'] ?? [];
$this->loadMonitorClass = $conf['loadMonitorClass'] ?? 'LoadMonitor';
- $this->maxLag = $conf['maxLag'] ?? self::MAX_LAG_DEFAULT;
}
/**
$this->baseLoadBalancerParams(),
[
'servers' => $servers,
- 'maxLag' => $this->maxLag,
'loadMonitor' => [ 'class' => $this->loadMonitorClass ],
]
) );
* - loadMonitor : Name of a class used to fetch server lag and load.
* - readOnlyReason : Reason the master DB is read-only if so [optional]
* - waitTimeout : Maximum time to wait for replicas for consistency [optional]
- * - maxLag: Avoid replica DB servers with more lag than this [optional]
+ * - maxLag: Try to avoid DB replicas with lag above this many seconds [optional]
* - srvCache : BagOStuff object for server cache [optional]
* - wanCache : WANObjectCache object [optional]
* - chronologyCallback: Callback to run before the first connection attempt [optional]
/** @var string Alternate ID string for the domain instead of DatabaseDomain::getId() */
private $localDomainIdAlias;
/** @var int */
- private $maxLag = self::MAX_LAG_DEFAULT;
+ private $maxLag;
/** @var string Current server name */
private $hostname;
$this->readOnlyReason = $params['readOnlyReason'];
}
- if ( isset( $params['maxLag'] ) ) {
- $this->maxLag = $params['maxLag'];
- }
+ $this->maxLag = $params['maxLag'] ?? self::MAX_LAG_DEFAULT;
$this->loadMonitorConfig = $params['loadMonitor'] ?? [ 'class' => 'LoadMonitorNull' ];
$this->loadMonitorConfig += [ 'lagWarnThreshold' => $this->maxLag ];