Add more information to reuseConnection() exceptions
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 5 Oct 2016 22:02:59 +0000 (15:02 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 5 Oct 2016 22:04:32 +0000 (15:04 -0700)
Change-Id: Id2e6b275c8dc074fde460424178a2bc54f303d65

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 ) {