* @return TransactionProfiler
*/
protected function getTransactionProfiler() {
- return $this->trxProfiler
- ? $this->trxProfiler
- : Profiler::instance()->getTransactionProfiler();
+ if ( !$this->trxProfiler ) {
+ $this->trxProfiler = new TransactionProfiler();
+ }
+
+ return $this->trxProfiler;
+ }
+
+ /**
+ * @param TransactionProfiler $profiler
+ * @since 1.27
+ */
+ public function setTransactionProfiler( TransactionProfiler $profiler ) {
+ $this->trxProfiler = $profiler;
}
/**
abstract class LBFactory {
/** @var ChronologyProtector */
protected $chronProt;
+ /** @var TransactionProfiler */
+ protected $trxProfiler;
/** @var LBFactory */
private static $instance;
}
$this->chronProt = $this->newChronologyProtector();
+ $this->trxProfiler = Profiler::instance()->getTransactionProfiler();
}
/**
return new LoadBalancer( array(
'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
'loadMonitor' => $this->loadMonitorClass,
- 'readOnlyReason' => $readOnlyReason
+ 'readOnlyReason' => $readOnlyReason,
+ 'trxProfiler' => $this->trxProfiler
) );
}
return new LoadBalancer( array(
'servers' => $servers,
'loadMonitor' => $this->loadMonitorClass,
- 'readOnlyReason' => $this->readOnlyReason
+ 'readOnlyReason' => $this->readOnlyReason,
+ 'trxProfiler' => $this->trxProfiler
) );
}
return new LoadBalancer( array(
'servers' => $wgExternalServers[$cluster],
'loadMonitor' => $this->loadMonitorClass,
- 'readOnlyReason' => $this->readOnlyReason
+ 'readOnlyReason' => $this->readOnlyReason,
+ 'trxProfiler' => $this->trxProfiler
) );
}
public function __construct( array $conf ) {
parent::__construct( $conf );
- $conf['readOnlyReason'] = $this->readOnlyReason;
- $this->lb = new LoadBalancerSingle( $conf );
+ $this->lb = new LoadBalancerSingle( array(
+ 'readOnlyReason' => $this->readOnlyReason,
+ 'trxProfiler' => $this->trxProfiler
+ ) + $conf );
}
/**
'dbname' => $this->db->getDBname(),
'load' => 1,
)
- )
+ ),
+ 'trxProfiler' => $this->trxProfiler
) );
if ( isset( $params['readOnlyReason'] ) ) {
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();
+ }
}
/**
$db->setLazyMasterHandle(
$this->getLazyConnectionRef( DB_MASTER, array(), $db->getWikiID() )
);
+ $db->setTransactionProfiler( $this->trxProfiler );
return $db;
}