$this->wanCache = $wCache;
$this->replLogger = new NullLogger();
- $this->movingAveRatio = isset( $options['movingAveRatio'] )
- ? $options['movingAveRatio']
- : 0.1;
- $this->lagWarnThreshold = isset( $options['lagWarnThreshold'] )
- ? $options['lagWarnThreshold']
- : self::LAG_WARN_THRESHOLD;
+ $this->movingAveRatio = $options['movingAveRatio'] ?? 0.1;
+ $this->lagWarnThreshold = $options['lagWarnThreshold'] ?? self::LAG_WARN_THRESHOLD;
}
public function setLogger( LoggerInterface $logger ) {
continue;
}
- $conn = $this->parent->getAnyOpenConnection( $i );
+ # Handles with open transactions are avoided since they might be subject
+ # to REPEATABLE-READ snapshots, which could affect the lag estimate query.
+ $flags = ILoadBalancer::CONN_TRX_AUTOCOMMIT;
+ $conn = $this->parent->getAnyOpenConnection( $i, $flags );
if ( $conn ) {
$close = false; // already open
} else {
- $conn = $this->parent->openConnection( $i, '' );
+ $conn = $this->parent->openConnection( $i, ILoadBalancer::DOMAIN_ANY, $flags );
$close = true; // new connection
}
- $lastWeight = isset( $staleValue['weightScales'][$i] )
- ? $staleValue['weightScales'][$i]
- : 1.0;
+ $lastWeight = $staleValue['weightScales'][$i] ?? 1.0;
$coefficient = $this->getWeightScale( $i, $conn ?: null );
$newWeight = $movAveRatio * $coefficient + ( 1 - $movAveRatio ) * $lastWeight;