From 433d57f00f10b7e1218034f1a7372f6ee8ccb142 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 19 Jun 2014 13:20:26 -0700 Subject: [PATCH] Set MYSQLI_OPT_CONNECT_TIMEOUT in mysqli * There is no php.ini setting for this, and it is unclear how high the default is. The retry behavior of MediaWiki also makes little sense without knowing this value. * Also removed the retry loop which will mostly result in giving up the position in some FIFO queue only to come back at the end of the line. Change-Id: Id24f6635508ba87288a2e40f71d4e8016a1805b0 --- includes/db/DatabaseMysqli.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php index 8c9b06c31a..b8d5d7925a 100644 --- a/includes/db/DatabaseMysqli.php +++ b/includes/db/DatabaseMysqli.php @@ -87,17 +87,12 @@ class DatabaseMysqli extends DatabaseMysqlBase { } else { $mysqli->options( MYSQLI_SET_CHARSET_NAME, 'binary' ); } + $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 ); - $numAttempts = 2; - for ( $i = 0; $i < $numAttempts; $i++ ) { - if ( $i > 1 ) { - usleep( 1000 ); - } - if ( $mysqli->real_connect( $realServer, $this->mUser, - $this->mPassword, $this->mDBname, $port, null, $connFlags ) - ) { - return $mysqli; - } + if ( $mysqli->real_connect( $realServer, $this->mUser, + $this->mPassword, $this->mDBname, $port, null, $connFlags ) + ) { + return $mysqli; } return false; -- 2.20.1