private $mAllowLagged;
/** @var integer Seconds to spend waiting on slave lag to resolve */
private $mWaitTimeout;
-
/** @var array LBFactory information */
private $mParentInfo;
+
/** @var string The LoadMonitor subclass name */
private $mLoadMonitorClass;
/** @var LoadMonitor */
/** @var integer Total connections opened */
private $connsOpened = 0;
+ /** @var TransactionProfiler */
+ protected $trxProfiler;
+
/** @var integer Warn when this many connection are held */
const CONN_HELD_WARN_THRESHOLD = 10;
/** @var integer Default 'max lag' when unspecified */
}
$this->srvCache = ObjectCache::getLocalServerInstance();
+
+ if ( isset( $params['trxProfiler'] ) ) {
+ $this->trxProfiler = $params['trxProfiler'];
+ } else {
+ $this->trxProfiler = new TransactionProfiler();
+ }
}
/**
if ( isset( $this->mServers[$i]['max lag'] ) ) {
$maxServerLag = min( $maxServerLag, $this->mServers[$i]['max lag'] );
}
+
+ $host = $this->getServerName( $i );
if ( $lag === false ) {
- wfDebugLog( 'replication', "Server #$i is not replicating" );
+ wfDebugLog( 'replication', "Server $host (#$i) is not replicating?" );
unset( $loads[$i] );
} elseif ( $lag > $maxServerLag ) {
- wfDebugLog( 'replication', "Server #$i is excessively lagged ($lag seconds)" );
+ wfDebugLog( 'replication', "Server $host (#$i) has >= $lag seconds of lag" );
unset( $loads[$i] );
}
}
*
* @param int $i Server index
* @param string|bool $wiki Wiki ID, or false for the current wiki
- * @return DatabaseBase
- *
- * @access private
+ * @return DatabaseBase|bool Returns false on errors
*/
public function openConnection( $i, $wiki = false ) {
if ( $wiki !== false ) {
$db->setLazyMasterHandle(
$this->getLazyConnectionRef( DB_MASTER, array(), $db->getWikiID() )
);
+ $db->setTransactionProfiler( $this->trxProfiler );
return $db;
}
|| $this->lastMasterChangeTimestamp() > microtime( true ) - $age );
}
+ /**
+ * Get the list of callers that have pending master changes
+ *
+ * @return array
+ * @since 1.27
+ */
+ public function pendingMasterChangeCallers() {
+ $fnames = array();
+
+ $masterIndex = $this->getWriterIndex();
+ foreach ( $this->mConns as $conns2 ) {
+ if ( empty( $conns2[$masterIndex] ) ) {
+ continue;
+ }
+ /** @var DatabaseBase $conn */
+ foreach ( $conns2[$masterIndex] as $conn ) {
+ $fnames = array_merge( $fnames, $conn->pendingWriteCallers() );
+ }
+ }
+
+ return $fnames;
+ }
+
/**
* @param mixed $value
* @return mixed