summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-03-28 16:14:17 +0200
committerGitHub <noreply@github.com>2018-03-28 16:14:17 +0200
commit575261c6d9e432ea181beedfc8086c24cc17ccc6 (patch)
tree823b804e2a6bf1a0427c09755f6d419e9ede3513
parent413d682cdbb1b0f266e99a891aa6786515fca6a2 (diff)
downloadbugzilla-575261c6d9e432ea181beedfc8086c24cc17ccc6.tar.gz
bugzilla-575261c6d9e432ea181beedfc8086c24cc17ccc6.tar.xz
Bug 1449156 - Bugzilla::Memcached should use smaller timeouts and ping servers at instantiation time
-rw-r--r--Bugzilla/Memcached.pm24
1 files changed, 19 insertions, 5 deletions
diff --git a/Bugzilla/Memcached.pm b/Bugzilla/Memcached.pm
index 136f43c61..d34aaa595 100644
--- a/Bugzilla/Memcached.pm
+++ b/Bugzilla/Memcached.pm
@@ -36,11 +36,25 @@ sub _new {
if (Bugzilla->feature('memcached') && $servers) {
$self->{namespace} = Bugzilla->localconfig->{memcached_namespace};
TRACE("connecting servers: $servers, namespace: $self->{namespace}");
- $self->{memcached} = Cache::Memcached::Fast->new({
- servers => [ _parse_memcached_server_list($servers) ],
- namespace => $self->{namespace},
- max_size => 1024 * 1024 * 4,
- });
+ $self->{memcached} = Cache::Memcached::Fast->new(
+ {
+ servers => [ _parse_memcached_server_list($servers) ],
+ namespace => $self->{namespace},
+ max_size => 1024 * 1024 * 4,
+ max_failures => 1,
+ failure_timeout => 60,
+ io_timeout => 0.2,
+ connect_timeout => 0.2,
+ }
+ );
+ my $versions = $self->{memcached}->server_versions;
+ if (keys %$versions) {
+ # this is needed to ensure forked processes don't start out with a connected memcached socket.
+ $self->{memcached}->disconnect_all;
+ }
+ else {
+ WARN("No memcached servers");
+ }
}
else {
TRACE("memcached feature is not enabled");