thanos-io/thanos · error
failed to create memcached client
Error message
failed to create memcached client
What it means
When the configured cache type is MEMCACHED, the factory creates a memcached client via cacheutil.NewMemcachedClient; failure is wrapped as 'failed to create memcached client'. This occurs before any network call — the client constructor itself rejects its configuration (addresses, timeouts, DNS setup).
Solutions
- Verify the addresses field lists reachable memcached hosts (correct service DNS name and port 11211)
- Check timeout/duration fields parse as Go durations (e.g. 500ms, 1s)
- Ensure the memcached Service/Endpoints exist and DNS resolves (kubectl get endpoints)
- Validate max_idle_connections and other client options are positive values
- Log the wrapped inner error — it names the exact invalid parameter
Example fix
// before addresses: memcached.invalid-namespace.svc:11211 // after addresses: memcached.monitoring.svc.cluster.local:11211 dns_provider_update_interval: 10s
Defensive patterns
Strategy: validation
Validate before calling
for _, a := range strings.Fields(memcachedAddresses) {
if _, _, err := net.SplitHostPort(a); err != nil { return fmt.Errorf("bad memcached address %q: %w", a, err) }
} Try / catch
cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)
if err != nil {
var se *status.Error
if strings.Contains(err.Error(), "failed to create memcached client") {
return fmt.Errorf("memcached addresses/timeout invalid; check DNS and durations: %w", err)
}
return err
} Prevention
- Verify memcached Service DNS resolves inside the cluster before rollout
- Use space-separated host list in the addresses field
- Express timeouts as Go durations (500ms, 1s)
- Ensure service discovery (SRV/DNS) provider settings are valid
When it happens
Trigger: CachingWithBackendConfig.Type == MEMCACHED and NewMemcachedClient returns an error, e.g. empty/invalid host list, unparseable addresses, invalid timeout/duration values, or failure resolving service DNS (SRV) addresses at construction.
Common situations: Kubernetes users pointing at a wrong memcached Service name or port, misconfigured addresses string (space-separated list), or invalid memcached_client_timeout values in the YAML.
Related errors
- failed to parse template
- failed to execute template
- error while parsing config for request logging
- getting http client config
- parsing http config YAML
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/f327ac333221a2a7.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/cache/caching_bucket_factory.go:115
var c cache.Cache
cfg := cache.NewCachingBucketConfig()
// Configure cache paths.
cfg.CacheAttributes("chunks", nil, isTSDBChunkFile, config.ChunkObjectAttrsTTL)
cfg.CacheGetRange("chunks", nil, isTSDBChunkFile, config.ChunkSubrangeSize, config.ChunkObjectAttrsTTL, config.ChunkSubrangeTTL, config.MaxChunksGetRangeRequests)
cfg.CacheExists("meta.jsons", nil, isMetaFile, config.MetafileExistsTTL, config.MetafileDoesntExistTTL)
cfg.CacheGet("meta.jsons", nil, isMetaFile, int(config.MetafileMaxSize), config.MetafileContentTTL, config.MetafileExistsTTL, config.MetafileDoesntExistTTL)
// Cache Iter requests for root.
cfg.CacheIter("blocks-iter", nil, isBlocksRootDir, config.BlocksIterTTL, JSONIterCodec{}, cfgHash)
switch strings.ToUpper(string(config.Type)) {
case string(MemcachedBucketCacheProvider):
var memcached cacheutil.RemoteCacheClient
memcached, err := cacheutil.NewMemcachedClient(logger, "caching-bucket", backendConfig, reg)
if err != nil {
return nil, errors.Wrapf(err, "failed to create memcached client")
}
c = cache.NewMemcachedCache("caching-bucket", logger, memcached, reg)
case string(InMemoryBucketCacheProvider):
c, err = cache.NewInMemoryCache("caching-bucket", logger, reg, backendConfig)
if err != nil {
return nil, errors.Wrapf(err, "failed to create inmemory cache")
}
case string(GroupcacheBucketCacheProvider):
const basePath = "/_galaxycache/"
c, err = cache.NewGroupcache(logger, reg, backendConfig, basePath, r, bucket, cfg)
if err != nil {
return nil, errors.Wrap(err, "failed to create groupcache")
}
case string(RedisBucketCacheProvider):
redisCache, err := cacheutil.NewRedisClient(logger, "caching-bucket", backendConfig, reg)
if err != nil {View on GitHub (pinned to 35b8b99117)