{"record":{"id":"f327ac333221a2a7","repo":"thanos-io/thanos","slug":"failed-to-create-memcached-client","errorCode":null,"errorMessage":"failed to create memcached client","messagePattern":"failed to create memcached client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/cache/caching_bucket_factory.go","lineNumber":115,"sourceCode":"\n\tvar c cache.Cache\n\tcfg := cache.NewCachingBucketConfig()\n\n\t// Configure cache paths.\n\tcfg.CacheAttributes(\"chunks\", nil, isTSDBChunkFile, config.ChunkObjectAttrsTTL)\n\tcfg.CacheGetRange(\"chunks\", nil, isTSDBChunkFile, config.ChunkSubrangeSize, config.ChunkObjectAttrsTTL, config.ChunkSubrangeTTL, config.MaxChunksGetRangeRequests)\n\tcfg.CacheExists(\"meta.jsons\", nil, isMetaFile, config.MetafileExistsTTL, config.MetafileDoesntExistTTL)\n\tcfg.CacheGet(\"meta.jsons\", nil, isMetaFile, int(config.MetafileMaxSize), config.MetafileContentTTL, config.MetafileExistsTTL, config.MetafileDoesntExistTTL)\n\n\t// Cache Iter requests for root.\n\tcfg.CacheIter(\"blocks-iter\", nil, isBlocksRootDir, config.BlocksIterTTL, JSONIterCodec{}, cfgHash)\n\n\tswitch strings.ToUpper(string(config.Type)) {\n\tcase string(MemcachedBucketCacheProvider):\n\t\tvar memcached cacheutil.RemoteCacheClient\n\t\tmemcached, err := cacheutil.NewMemcachedClient(logger, \"caching-bucket\", backendConfig, reg)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to create memcached client\")\n\t\t}\n\t\tc = cache.NewMemcachedCache(\"caching-bucket\", logger, memcached, reg)\n\tcase string(InMemoryBucketCacheProvider):\n\t\tc, err = cache.NewInMemoryCache(\"caching-bucket\", logger, reg, backendConfig)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to create inmemory cache\")\n\t\t}\n\tcase string(GroupcacheBucketCacheProvider):\n\t\tconst basePath = \"/_galaxycache/\"\n\n\t\tc, err = cache.NewGroupcache(logger, reg, backendConfig, basePath, r, bucket, cfg)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to create groupcache\")\n\t\t}\n\n\tcase string(RedisBucketCacheProvider):\n\t\tredisCache, err := cacheutil.NewRedisClient(logger, \"caching-bucket\", backendConfig, reg)\n\t\tif err != nil {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/caching_bucket_factory.go#L97-L133","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\naddresses: memcached.invalid-namespace.svc:11211\n// after\naddresses: memcached.monitoring.svc.cluster.local:11211\ndns_provider_update_interval: 10s","handlingStrategy":"validation","validationCode":"for _, a := range strings.Fields(memcachedAddresses) {\n    if _, _, err := net.SplitHostPort(a); err != nil { return fmt.Errorf(\"bad memcached address %q: %w\", a, err) }\n}","typeGuard":null,"tryCatchPattern":"cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)\nif err != nil {\n    var se *status.Error\n    if strings.Contains(err.Error(), \"failed to create memcached client\") {\n        return fmt.Errorf(\"memcached addresses/timeout invalid; check DNS and durations: %w\", err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","memcached","config","thanos"],"backgroundTag":"module-init-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}