/** @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;
const CONN_HELD_WARN_THRESHOLD = 10;
/** @var int Default 'maxLag' when unspecified */
- const MAX_LAG_DEFAULT = 10;
+ const MAX_LAG_DEFAULT = 6;
/** @var int Default 'waitTimeout' when unspecified */
const MAX_WAIT_DEFAULT = 10;
/** @var int Seconds to cache master server read-only status */
$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 ];
$host = $this->getServerName( $i );
if ( $lag === false && !is_infinite( $maxServerLag ) ) {
- $this->replLogger->error(
+ $this->replLogger->debug(
__METHOD__ .
": server {host} is not replicating?", [ 'host' => $host ] );
unset( $loads[$i] );
* Test if the specified index represents an open connection
*
* @param int $index Server index
- * @access private
+ * @private
* @return bool
*/
private function isOpen( $index ) {
}
}
- /**
- * @param IDatabase $conn
- * @param DBMasterPos|bool $pos
- * @param int|null $timeout
- * @return bool
- */
public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
$timeout = max( 1, $timeout ?: $this->waitTimeout );
$pos = $masterConn->getMasterPos();
} else {
$masterConn = $this->openConnection( $this->getWriterIndex(), self::DOMAIN_ANY );
+ if ( !$masterConn ) {
+ throw new DBReplicationWaitError(
+ null,
+ "Could not obtain a master database connection to get the position"
+ );
+ }
$pos = $masterConn->getMasterPos();
$this->closeConnection( $masterConn );
}