{"record":{"id":"1e458c7267b84f56","repo":"thanos-io/thanos","slug":"create-s-index-cache","errorCode":null,"errorMessage":"create %s index cache","messagePattern":"create (.+?) index cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/cache/factory.go","lineNumber":78,"sourceCode":"\tcase string(INMEMORY):\n\t\tcache, err = NewInMemoryIndexCache(logger, cacheMetrics, reg, backendConfig)\n\tcase string(MEMCACHED):\n\t\tvar memcached cacheutil.RemoteCacheClient\n\t\tmemcached, err = cacheutil.NewMemcachedClient(logger, \"index-cache\", backendConfig, reg)\n\t\tif err == nil {\n\t\t\tcache, err = NewRemoteIndexCache(logger, memcached, cacheMetrics, reg, cacheConfig.TTL)\n\t\t}\n\tcase string(REDIS):\n\t\tvar redisCache cacheutil.RemoteCacheClient\n\t\tredisCache, err = cacheutil.NewRedisClient(logger, \"index-cache\", backendConfig, reg)\n\t\tif err == nil {\n\t\t\tcache, err = NewRemoteIndexCache(logger, redisCache, cacheMetrics, reg, cacheConfig.TTL)\n\t\t}\n\tdefault:\n\t\treturn nil, errors.Errorf(\"index cache with type %s is not supported\", cacheConfig.Type)\n\t}\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, fmt.Sprintf(\"create %s index cache\", cacheConfig.Type))\n\t}\n\n\tcache = NewTracingIndexCache(string(cacheConfig.Type), cache)\n\tif len(cacheConfig.EnabledItems) > 0 {\n\t\tif err = ValidateEnabledItems(cacheConfig.EnabledItems); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcache = NewFilteredIndexCache(cache, cacheConfig.EnabledItems)\n\t}\n\n\treturn cache, nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":91,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/factory.go#L60-L91","documentation":"Once the concrete index cache backend is constructed, any error from that construction (memcached/redis client creation, in-memory size validation, remote index cache init) is wrapped with 'create %s index cache' naming the chosen type. It identifies which backend failed during its own setup, not which specific sub-error occurred.","triggerScenarios":"Calling NewIndexCache with a valid type but failing backend config, e.g. memcached with unparseable addresses, redis with a bad address/timeout value, or in-memory config where max_item_size > max_size.","commonSituations":"Redis/memcached endpoint typos; invalid duration or size strings in backend config; in-memory cache sized incorrectly; network-unreachable addresses passed but only detected lazily.","solutions":["Read the wrapped cause below this message to find the backend-specific failure.","Fix the backend config block (addresses, timeouts, sizes) for the cache type named in the message.","For in-memory, ensure config.max_item_size <= config.max_size.","Verify connectivity to remote cache endpoints (DNS, ports, auth)."],"exampleFix":"// before\nindex-cache:\n  type: memcached\n  config:\n    addresses: \"memcached:11211\"\n// after\nindex-cache:\n  type: memcached\n  config:\n    addresses: [\"memcached:11211\"]","handlingStrategy":"try-catch","validationCode":"// Validate backend config block shape before init\nvar cfg struct {\n\tType   string                 `yaml:\"type\"`\n\tConfig map[string]interface{} `yaml:\"config\"`\n}\nif err := yaml.Unmarshal(confYaml, &cfg); err != nil { return err }\nif cfg.Type == \"memcached\" {\n\tif v, ok := cfg.Config[\"addresses\"]; ok {\n\t\tif _, ok := v.([]interface{}); !ok {\n\t\t\treturn errors.New(\"memcached addresses must be a list\")\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"if _, err := storecache.NewIndexCache(logger, confYaml, reg); err != nil {\n\tif strings.Contains(err.Error(), \"index cache\") {\n\t\tlogger.Error(\"cache backend init failed\", \"err\", err) // unwrap cause for backend-specific fix\n\t}\n\treturn err\n}","preventionTips":["Validate addresses/timeouts/sizes for the chosen backend before startup.","Smoke-test connectivity to memcached/redis in readiness probes.","Read the wrapped inner error, not just the outer wrap message."],"tags":["config","cache","initialization"],"backgroundTag":"invalid-config-value","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"}