{"record":{"id":"86e7bc37f36703f9","repo":"juicedata/juicefs","slug":"unknown-cache-eviction-policy-q","errorCode":null,"errorMessage":"unknown cache eviction policy: %q","messagePattern":"unknown cache eviction policy: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/cache_eviction.go","lineNumber":69,"sourceCode":"\tevictionIter() func(yield func(key cacheKey, item cacheItem) bool)\n}\n\nfunc NewKeyIndex(config *Config) (KeyIndex, error) {\n\tswitch config.CacheEviction {\n\tcase EvictionNone:\n\t\treturn &noneEviction{keys: make(map[cacheKey]cacheItem)}, nil\n\tcase Eviction2Random:\n\t\treturn &randomEviction{\n\t\t\tnoneEviction: noneEviction{keys: make(map[cacheKey]cacheItem)},\n\t\t\tcacheExpire:  config.CacheExpire,\n\t\t}, nil\n\tcase EvictionLRU:\n\t\treturn &lruEviction{\n\t\t\tkeys:    make(map[cacheKey]*lruItem),\n\t\t\tlruHeap: atimeHeap{},\n\t\t}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown cache eviction policy: %q\", config.CacheEviction)\n\t}\n}\n\n// noneEviction is a policy that does nothing.\ntype noneEviction struct {\n\tkeys map[cacheKey]cacheItem\n}\n\nfunc (p *noneEviction) name() string {\n\treturn EvictionNone\n}\n\nfunc (p *noneEviction) add(key cacheKey, item cacheItem) {\n\tp.keys[key] = item\n}\n\nfunc (p *noneEviction) remove(key cacheKey, staging bool) *cacheItem {\n\titem, ok := p.keys[key]","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/cache_eviction.go#L51-L87","documentation":"JuiceFS's disk cache layer supports several eviction policies (none, LRU, etc.) selected via the CacheEviction config value. NewKeyIndex parses that string into a policy object; if the configured value does not match any known policy, construction fails with this error. It is a config validation error thrown at cache-store creation time.","triggerScenarios":"Passing an unrecognized value in CacheEviction (e.g. via the --cache-eviction mount/CLI option or chunk store config) such as a typo ('lru2', 'random', case-sensitive mismatch) or a policy string from a newer/older JuiceFS version that this binary does not support.","commonSituations":"Copy-pasting mount options from documentation or another cluster running a different JuiceFS version; typos in cache-eviction flags in systemd units or KubernetesCSI configs; configuration migration where a policy name was renamed.","solutions":["Set CacheEviction to a supported value: check pkg/chunk/cache_eviction.go for accepted names (e.g. 'none', 'lru') and use one exactly (case-sensitive).","Remove the --cache-eviction flag entirely to use the default policy.","Check the JuiceFS version: `juicefs -V`; policy names may differ between versions, align config with that version's docs.","If the value comes from an environment template or operator config, fix it at the source so all clients receive a valid policy."],"exampleFix":"// before\njuicefs mount --cache-eviction lru2 sqlite3://test.db /mnt/jfs\n// after\njuicefs mount --cache-eviction lru sqlite3://test.db /mnt/jfs","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"none\": true, \"lru\": true}\nif !allowed[config.CacheEviction] {\n    return fmt.Errorf(\"unsupported --cache-eviction %q; use one of: none, lru\", config.CacheEviction)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate cache-eviction flags in deployment templates before rollout","Pin config values to the JuiceFS version's documented options","Check `juicefs -V` and matching docs when copying mount options between clusters"],"tags":["config","cache","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}