// This method runs after the new revisions were committed.
// Wait for the replica to catch up so they will all be counted.
$dbr->flushSnapshot( $fname );
- $lb->safeWaitForMasterPos( $dbr );
+ $lb->waitForMasterPos( $dbr );
}
$affectedInstances[0]->initEditCountInternal();
}
return false; // deleted?
}
- // Cut down on the time spent in safeWaitForMasterPos() in the critical section
+ // Cut down on the time spent in waitForMasterPos() in the critical section
$dbr = $lb->getConnection( DB_REPLICA, [ 'recentchanges' ] );
- if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$lb->waitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while pre-waiting for replica DB to catch up" );
return false;
}
}
// Wait till replica DB is caught up so that jobs for this page see each others' changes
- if ( !$lb->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$lb->waitForMasterPos( $dbr ) ) {
$this->setLastError( "Timed out while waiting for replica DB to catch up" );
return false;
}
$dbr = $loadBalancer->getConnection( DB_REPLICA, [ 'watchlist' ] );
// Wait before lock to try to reduce time waiting in the lock.
- if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
$this->setLastError( 'Timed out waiting for replica to catch up before lock' );
return false;
}
return false;
}
- if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) {
+ if ( !$loadBalancer->waitForMasterPos( $dbr ) ) {
$this->setLastError( 'Timed out waiting for replica to catch up within lock' );
return false;
}
* @param DBMasterPos|bool $pos Master position; default: current position
* @param int $timeout Timeout in seconds [optional]
* @return bool Success
+ * @since 1.34
*/
- public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
+ public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 );
/**
* Set a callback via IDatabase::setTransactionListener() on
return $conn->getLag();
}
- public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+ public function waitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
$timeout = max( 1, $timeout ?: $this->waitTimeout );
if ( $this->getServerCount() <= 1 || !$conn->getLBInfo( 'replica' ) ) {
return $ok;
}
+ /**
+ * Wait for a replica DB to reach a specified master position
+ *
+ * This will connect to the master to get an accurate position if $pos is not given
+ *
+ * @param IDatabase $conn Replica DB
+ * @param DBMasterPos|bool $pos Master position; default: current position
+ * @param int $timeout Timeout in seconds [optional]
+ * @return bool Success
+ * @since 1.28
+ * @deprecated Since 1.34 Use waitForMasterPos() instead
+ */
+ public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
+ return $this->waitForMasterPos( $conn, $pos, $timeout );
+ }
+
public function setTransactionListener( $name, callable $callback = null ) {
if ( $callback ) {
$this->trxRecurringCallbacks[$name] = $callback;