From 3defb5a11a9f6a9a5cd890865cd086de4c7b30df Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 4 May 2017 15:07:11 +1000 Subject: [PATCH] EtcdConfig: Fix infinite timeout bug, and reduce timeout removeServer() returns the modified array, rather than passing by reference, so you have to use the return value to avoid an infinite loop when a server is down. Tune the timeout downwards, to 2s. With three servers in the SRV pool, if they are all unreachable, this will mean an overall request time of 6s, which is conveniently less than the APC lock time and the cache TTL (9-10s). If the APC lock time is significantly shorter than the time it takes to do the HTTP requests, then additional threads join in waiting for the server. This could have stability consequences if the maximum HHVM worker count is exceeded. Change-Id: I3176aa41b8833c0ba0b668859e59911cd4392250 --- includes/config/EtcdConfig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php index fd5c3f705a..880cf9ff8c 100644 --- a/includes/config/EtcdConfig.php +++ b/includes/config/EtcdConfig.php @@ -73,7 +73,7 @@ class EtcdConfig implements Config, LoggerAwareInterface { 'encoding' => 'JSON', 'cacheTTL' => 10, 'skewTTL' => 1, - 'timeout' => 10 + 'timeout' => 2 ]; $this->host = $params['host']; @@ -215,7 +215,7 @@ class EtcdConfig implements Config, LoggerAwareInterface { } // Avoid the server next time if that failed - $dsd->removeServer( $server, $servers ); + $servers = $dsd->removeServer( $server, $servers ); } while ( $servers ); return [ $config, $error, $retry ]; -- 2.20.1