Merge "Add more information to reuseConnection() exceptions"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 5 Oct 2016 22:14:42 +0000 (22:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 5 Oct 2016 22:14:42 +0000 (22:14 +0000)
includes/libs/rdbms/loadbalancer/LoadBalancer.php

index 9f1021d..66e4fcf 100644 (file)
@@ -615,9 +615,12 @@ class LoadBalancer implements ILoadBalancer {
                }
 
                $domain = $conn->getDomainID();
-               if ( $this->mConns['foreignUsed'][$serverIndex][$domain] !== $conn ) {
+               if ( !isset( $this->mConns['foreignUsed'][$serverIndex][$domain] ) ) {
                        throw new InvalidArgumentException( __METHOD__ .
-                               ": connection not found, has the connection been freed already?" );
+                               ": connection $serverIndex/$domain not found; it may have already been freed." );
+               } elseif ( $this->mConns['foreignUsed'][$serverIndex][$domain] !== $conn ) {
+                       throw new InvalidArgumentException( __METHOD__ .
+                               ": connection $serverIndex/$domain mismatched; it may have already been freed." );
                }
                $conn->setLBInfo( 'foreignPoolRefCount', --$refCount );
                if ( $refCount <= 0 ) {