From: Aaron Schulz Date: Wed, 19 Jun 2019 16:28:09 +0000 (+0100) Subject: rdbms: rename safeWaitForMasterPos() to waitForMasterPos() in ILoadBalancer X-Git-Tag: 1.34.0-rc.0~1307 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=6718d18339ca04a4832293ae95bce49ddcd4c6bf;p=lhc%2Fweb%2Fwiklou.git rdbms: rename safeWaitForMasterPos() to waitForMasterPos() in ILoadBalancer Change-Id: I2ad0c6f369ba992895a5306a57f1af16a772844c --- diff --git a/includes/deferred/UserEditCountUpdate.php b/includes/deferred/UserEditCountUpdate.php index 4ce0b18ec6..e9ebabb643 100644 --- a/includes/deferred/UserEditCountUpdate.php +++ b/includes/deferred/UserEditCountUpdate.php @@ -89,7 +89,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { // 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(); } diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php index 3aedc38f5f..be76fc63b3 100644 --- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php +++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php @@ -91,9 +91,9 @@ class CategoryMembershipChangeJob extends Job { 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; } @@ -107,7 +107,7 @@ class CategoryMembershipChangeJob extends Job { } // 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; } diff --git a/includes/jobqueue/jobs/ClearUserWatchlistJob.php b/includes/jobqueue/jobs/ClearUserWatchlistJob.php index 0cb1a52d69..1793053a45 100644 --- a/includes/jobqueue/jobs/ClearUserWatchlistJob.php +++ b/includes/jobqueue/jobs/ClearUserWatchlistJob.php @@ -44,7 +44,7 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob { $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; } @@ -57,7 +57,7 @@ class ClearUserWatchlistJob extends Job implements GenericParameterJob { return false; } - if ( !$loadBalancer->safeWaitForMasterPos( $dbr ) ) { + if ( !$loadBalancer->waitForMasterPos( $dbr ) ) { $this->setLastError( 'Timed out waiting for replica to catch up within lock' ); return false; } diff --git a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php index f0d071b126..4d148b4c90 100644 --- a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php @@ -649,8 +649,9 @@ interface ILoadBalancer { * @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 diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 3936271531..c08655cb6a 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1994,7 +1994,7 @@ class LoadBalancer implements ILoadBalancer { 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' ) ) { @@ -2052,6 +2052,22 @@ class LoadBalancer implements ILoadBalancer { 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;