Add debugging logging to LoadBalancer connection closes
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 20 Sep 2016 18:06:59 +0000 (11:06 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 20 Sep 2016 18:06:59 +0000 (11:06 -0700)
This matches the logging used for opening new connections and can be
useful for seeing connection leakage.

Change-Id: I8d24d059062f3b698e64751b46542eb1fa78bb36

includes/libs/rdbms/loadbalancer/LoadBalancer.php

index c07d38f..791e5ad 100644 (file)
@@ -937,6 +937,8 @@ class LoadBalancer implements ILoadBalancer {
 
        public function closeAll() {
                $this->forEachOpenConnection( function ( IDatabase $conn ) {
+                       $host = $conn->getServer();
+                       $this->connLogger->debug( "Closing connection to database '$host'." );
                        $conn->close();
                } );
 
@@ -957,6 +959,8 @@ class LoadBalancer implements ILoadBalancer {
 
                        foreach ( $connsByServer[$serverIndex] as $i => $trackedConn ) {
                                if ( $conn === $trackedConn ) {
+                                       $host = $this->getServerName( $i );
+                                       $this->connLogger->debug( "Closing connection to database $i at '$host'." );
                                        unset( $this->mConns[$type][$serverIndex][$i] );
                                        --$this->connsOpened;
                                        break 2;