Chad has submitted this change and it was merged.

Change subject: Only retry on connection errors
......................................................................


Only retry on connection errors

This has the nice side effect of giving up immediately on any other sort
of errors.  It only does that because we have a single node set up via LVS.

Also fix some complaints about "the config 'host' is not found".  'host'
isn't a config.  It is a property.  I don't have any clue why, but it is.

A part of fixing this bug:
Bug: 57215

Change-Id: I42b592f1e3d773e9f2f88733a0496f8be6944dbf
---
M ElasticaConnection.php
1 file changed, 11 insertions(+), 4 deletions(-)

Approvals:
  Chad: Verified; Looks good to me, approved



diff --git a/ElasticaConnection.php b/ElasticaConnection.php
index d395e1b..372dc2b 100644
--- a/ElasticaConnection.php
+++ b/ElasticaConnection.php
@@ -60,14 +60,21 @@
                                 * @param \ElasticaConnection $me Child class 
of us
                                 */
                                function( $connection, $e ) use ( $me ) {
+                                       // We only want to try to reconnect on 
http connection errors
+                                       // Beyond that we want to give up fast. 
 Configuring a single connection
+                                       // through LVS accomplishes this.
+                                       if ( !( $e instanceof 
\Elastica\Exception\Connection\HttpException ) ||
+                                                       $e->getError() !== 
CURLE_COULDNT_CONNECT ) {
+                                               return;
+                                       }
                                        // Keep track of the number of times 
we've hit a host
                                        static $connectionAttempts = array();
-                                       $host = $connection->getConfig( 'host' 
);
-                                       $connectionAttempts[$host] = isset( 
$connectionAttempts[$host] )
-                                               ? $connectionAttempts[$host] + 
1 : 1;
+                                       $host = $connection->getParam( 'host' );
+                                       $connectionAttempts[ $host ] = isset( 
$connectionAttempts[ $host ] )
+                                               ? $connectionAttempts[ $host ] 
+ 1 : 1;
 
                                        // Check if we've hit the host the max 
# of times. If not, try again
-                                       if ( $connectionAttempts[$host] < 
$me->getMaxConnectionAttempts() ) {
+                                       if ( $connectionAttempts[ $host ] < 
$me->getMaxConnectionAttempts() ) {
                                                $connection->setEnabled( true );
                                        }
                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/96492
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I42b592f1e3d773e9f2f88733a0496f8be6944dbf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Elastica
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to