namespace Wikimedia\Rdbms;
-use IDatabase;
use InvalidArgumentException;
/**
/** @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] ) ) {
public function getMainLB( $domain = false ) {
$section = $this->getSectionForDomain( $domain );
if ( !isset( $this->mainLBs[$section] ) ) {
- $lb = $this->newMainLB( $domain );
- $this->getChronologyProtector()->initLB( $lb );
- $this->mainLBs[$section] = $lb;
+ $this->mainLBs[$section] = $this->newMainLB( $domain );
}
return $this->mainLBs[$section];
public function getExternalLB( $cluster ) {
if ( !isset( $this->extLBs[$cluster] ) ) {
$this->extLBs[$cluster] = $this->newExternalLB( $cluster );
- $this->getChronologyProtector()->initLB( $this->extLBs[$cluster] );
}
return $this->extLBs[$cluster];
$this->baseLoadBalancerParams(),
[
'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
+ 'maxLag' => $this->maxLag,
'loadMonitor' => [ 'class' => $this->loadMonitorClass ],
'readOnlyReason' => $readOnlyReason
]