From: Tim Starling Date: Thu, 4 May 2017 05:07:11 +0000 (+1000) Subject: EtcdConfig: Fix infinite timeout bug, and reduce timeout X-Git-Tag: 1.31.0-rc.0~3335^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=3defb5a11a9f6a9a5cd890865cd086de4c7b30df;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ];