'POST' => [
'readQueryTime' => 5,
'writeQueryTime' => 1,
- 'maxAffected' => 500
+ 'maxAffected' => 1000
],
'POST-nonwrite' => [
'masterConns' => 0,
'PostSend' => [
'readQueryTime' => 5,
'writeQueryTime' => 1,
- 'maxAffected' => 500
+ 'maxAffected' => 1000
],
// Background job runner
'JobRunner' => [
return $this->lazyMasterHandle;
}
- /**
- * @return TransactionProfiler
- */
- protected function getTransactionProfiler() {
- return $this->trxProfiler;
- }
-
/**
* @param TransactionProfiler $profiler
* @since 1.27
# Keep track of whether the transaction has write queries pending
if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $isWrite ) {
$this->mTrxDoneWrites = true;
- $this->getTransactionProfiler()->transactionWritingIn(
+ $this->trxProfiler->transactionWritingIn(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
$this->mRTTEstimate = $queryRuntime;
}
- $this->getTransactionProfiler()->recordQueryCompletion(
+ $this->trxProfiler->recordQueryCompletion(
$queryProf, $startTime, $isWrite, $this->affectedRows()
);
MWDebug::query( $sql, $fname, $isMaster, $queryRuntime );
$this->doCommit( $fname );
if ( $this->mTrxDoneWrites ) {
$this->mDoneWrites = microtime( true );
- $this->getTransactionProfiler()->transactionWritingOut(
+ $this->trxProfiler->transactionWritingOut(
$this->mServer, $this->mDBname, $this->mTrxShortId, $writeTime );
}
$this->doRollback( $fname );
$this->mTrxAtomicLevels = [];
if ( $this->mTrxDoneWrites ) {
- $this->getTransactionProfiler()->transactionWritingOut(
+ $this->trxProfiler->transactionWritingOut(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
*
* @param IDatabase $conn Replica DB
* @param DBMasterPos|bool $pos Master position; default: current position
- * @param integer $timeout Timeout in seconds
+ * @param integer|null $timeout Timeout in seconds [optional]
* @return bool Success
* @since 1.27
*/
- public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 ) {
+ public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
if ( $this->getServerCount() == 1 || !$conn->getLBInfo( 'replica' ) ) {
return true; // server is not a replica DB
}
return false; // something is misconfigured
}
+ $timeout = $timeout ?: $this->mWaitTimeout;
$result = $conn->masterPosWait( $pos, $timeout );
if ( $result == -1 || is_null( $result ) ) {
$msg = __METHOD__ . ": Timed out waiting on {$conn->getServer()} pos {$pos}";
* @file
* @author Aaron Schulz
*/
+use MediaWiki\MediaWikiServices;
/**
* Class to handle job queues stored in the DB
* @return void
*/
protected function doWaitForBackups() {
- wfWaitForSlaves( false, $this->wiki, $this->cluster ?: false );
+ $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $lbFactory->waitForReplication( [ 'wiki' => $this->wiki, 'cluster' => $this->cluster ] );
}
/**
* @return DBConnRef
*/
protected function getDB( $index ) {
+ $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$lb = ( $this->cluster !== false )
- ? wfGetLBFactory()->getExternalLB( $this->cluster, $this->wiki )
- : wfGetLB( $this->wiki );
+ ? $lbFactory->getExternalLB( $this->cluster, $this->wiki )
+ : $lbFactory->getMainLB( $this->wiki );
return $lb->getConnectionRef( $index, [], $this->wiki );
}
// enqueued will be reflected in backlink page parses when the leaf jobs run.
if ( !isset( $params['range'] ) ) {
try {
- wfGetLBFactory()->waitForReplication( [
+ $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $lbFactory->waitForReplication( [
'wiki' => wfWikiID(),
'timeout' => self::LAG_WAIT_TIMEOUT
] );
* @return bool
*/
protected function runForTitle( Title $title ) {
- $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+ $services = MediaWikiServices::getInstance();
+ $stats = $services->getStatsdDataFactory();
+ $lbFactory = $services->getDBLoadBalancerFactory();
+ $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
$page = WikiPage::factory( $title );
$page->loadPageData( WikiPage::READ_LATEST );
// Serialize links updates by page ID so they see each others' changes
- $scopedLock = LinksUpdate::acquirePageLock( wfGetDB( DB_MASTER ), $page->getId(), 'job' );
+ $dbw = $lbFactory->getMainLB()->getConnection( DB_MASTER );
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scopedLock = LinksUpdate::acquirePageLock( $dbw, $page->getId(), 'job' );
// Get the latest ID *after* acquirePageLock() flushed the transaction.
// This is used to detect edits/moves after loadPageData() but before the scope lock.
// The works around the chicken/egg problem of determining the scope lock key.
$parserOutput
);
- $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
- $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
foreach ( $updates as $key => $update ) {
- $update->setTransactionTicket( $ticket );
// FIXME: This code probably shouldn't be here?
// Needed by things like Echo notifications which need
// to know which user caused the links update
}
foreach ( $updates as $update ) {
+ $update->setTransactionTicket( $ticket );
$update->doUpdate();
}