rdbms: rename safeWaitForMasterPos() to waitForMasterPos() in ILoadBalancer
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 19 Jun 2019 16:28:09 +0000 (17:28 +0100)
committerKrinkle <krinklemail@gmail.com>
Sat, 22 Jun 2019 14:56:35 +0000 (14:56 +0000)
Change-Id: I2ad0c6f369ba992895a5306a57f1af16a772844c

includes/deferred/UserEditCountUpdate.php
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
includes/jobqueue/jobs/ClearUserWatchlistJob.php
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php

index 4ce0b18..e9ebabb 100644 (file)
@@ -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();
                                }
index 3aedc38..be76fc6 100644 (file)
@@ -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;
                }
index 0cb1a52..1793053 100644 (file)
@@ -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;
                }
index f0d071b..4d148b4 100644 (file)
@@ -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
index 3936271..c08655c 100644 (file)
@@ -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;