/** @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', 'loadMonitorClass' ];
+ 'readOnlyBySection', 'maxLag', '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->loadMonitorClass = isset( $conf['loadMonitorClass'] )
? $conf['loadMonitorClass']
: 'LoadMonitor';
+ $this->maxLag = isset( $conf['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]
* - srvCache : BagOStuff object for server cache [optional]
* - wanCache : WANObjectCache object [optional]
* - chronologyProtector: ChronologyProtector object [optional]
private $disabled = false;
/** @var bool */
private $chronProtInitialized = false;
+ /** @var int */
+ private $maxLag = self::MAX_LAG_DEFAULT;
/** @var int Warn when this many connection are held */
const CONN_HELD_WARN_THRESHOLD = 10;
- /** @var int Default 'max lag' when unspecified */
+ /** @var int Default 'maxLag' when unspecified */
const MAX_LAG_DEFAULT = 10;
/** @var int Seconds to cache master server read-only status */
const TTL_CACHE_READONLY = 5;
$this->readOnlyReason = $params['readOnlyReason'];
}
+ if ( isset( $params['maxLag'] ) ) {
+ $this->maxLag = $params['maxLag'];
+ }
+
if ( isset( $params['loadMonitor'] ) ) {
$this->loadMonitorConfig = $params['loadMonitor'];
} else {
# How much lag this server nominally is allowed to have
$maxServerLag = isset( $this->mServers[$i]['max lag'] )
? $this->mServers[$i]['max lag']
- : self::MAX_LAG_DEFAULT; // default
+ : $this->maxLag; // default
# Constrain that futher by $maxLag argument
$maxServerLag = min( $maxServerLag, $maxLag );