Make getLaggedSlaveMode() use reuseConnection() as needed
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 10 Nov 2015 20:18:00 +0000 (12:18 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 10 Nov 2015 20:20:58 +0000 (12:20 -0800)
Bug: T118162
Change-Id: I03e1386b952a9e9243518c12fb175727f81c9976

includes/db/loadbalancer/LoadBalancer.php

index 65ee9c7..052a0fa 100644 (file)
@@ -594,7 +594,6 @@ class LoadBalancer {
                $refCount = $conn->getLBInfo( 'foreignPoolRefCount' );
                if ( $serverIndex === null || $refCount === null ) {
                        wfDebug( __METHOD__ . ": this connection was not opened as a foreign connection\n" );
-
                        /**
                         * This can happen in code like:
                         *   foreach ( $dbs as $db ) {
@@ -605,7 +604,6 @@ class LoadBalancer {
                         * When a connection to the local DB is opened in this way, reuseConnection()
                         * should be ignored
                         */
-
                        return;
                }
 
@@ -1173,7 +1171,8 @@ class LoadBalancer {
                if ( !$this->laggedSlaveMode && $this->getServerCount() > 1 ) {
                        try {
                                // See if laggedSlaveMode gets set
-                               $this->getConnection( DB_SLAVE, false, $wiki );
+                               $conn = $this->getConnection( DB_SLAVE, false, $wiki );
+                               $this->reuseConnection( $conn );
                        } catch ( DBConnectionError $e ) {
                                // Avoid expensive re-connect attempts and failures
                                $this->slavesDownMode = true;