Merge "Provide correct type as input for LoadMonitor::postConnectionBackoff()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 22 Jan 2014 22:06:12 +0000 (22:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 22 Jan 2014 22:06:12 +0000 (22:06 +0000)
1  2 
includes/db/LoadBalancer.php

@@@ -29,8 -29,6 +29,8 @@@
   */
  class LoadBalancer {
        private $mServers, $mConns, $mLoads, $mGroupLoads;
 +
 +      /** @var bool|DatabaseBase Database connection that caused a problem */
        private $mErrorConnection;
        private $mReadIndex, $mAllowLagged;
  
  
                                // Perform post-connection backoff
                                $threshold = isset( $this->mServers[$i]['max threads'] )
-                                       ? $this->mServers[$i]['max threads'] : false;
+                                       ? $this->mServers[$i]['max threads'] : 0;
                                $backoff = $this->getLoadMonitor()->postConnectionBackoff( $conn, $threshold );
  
                                // Decrement reference counter, we are finished with this connection.
        /**
         * Returns true if the specified index is a valid server index
         *
 -       * @param $i
 +       * @param string $i
         * @return bool
         */
        function haveIndex( $i ) {
        /**
         * Returns true if the specified index is valid and has non-zero load
         *
 -       * @param $i
 +       * @param string $i
         * @return bool
         */
        function isNonZeroLoad( $i ) {
        /**
         * Get the host name or IP address of the server with the specified index
         * Prefer a readable name if available.
 -       * @param $i
 +       * @param string $i
         * @return string
         */
        function getServerName( $i ) {
        function closeAll() {
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
 +                              /** @var DatabaseBase $conn */
                                foreach ( $conns3 as $conn ) {
                                        $conn->close();
                                }
         * Deprecated function, typo in function name
         *
         * @deprecated in 1.18
 -       * @param $conn
 +       * @param DatabaseBase $conn
         */
        function closeConnecton( $conn ) {
                wfDeprecated( __METHOD__, '1.18' );
         * Close a connection
         * Using this function makes sure the LoadBalancer knows the connection is closed.
         * If you use $conn->close() directly, the load balancer won't update its state.
 -       * @param $conn DatabaseBase
 +       * @param DatabaseBase $conn
         */
        function closeConnection( $conn ) {
                $done = false;
        function commitAll() {
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
 +                              /** @var DatabaseBase[] $conns3 */
                                foreach ( $conns3 as $conn ) {
                                        if ( $conn->trxLevel() ) {
                                                $conn->commit( __METHOD__, 'flush' );
                        if ( empty( $conns2[$masterIndex] ) ) {
                                continue;
                        }
 +                      /** @var DatabaseBase $conn */
                        foreach ( $conns2[$masterIndex] as $conn ) {
                                if ( $conn->trxLevel() && $conn->writesOrCallbacksPending() ) {
                                        $conn->commit( __METHOD__, 'flush' );
                $success = true;
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
 +                              /** @var DatabaseBase[] $conns3 */
                                foreach ( $conns3 as $conn ) {
                                        if ( !$conn->ping() ) {
                                                $success = false;