Repository navigation
Description
Summary
cache.NewFromConfig is the only reader of cluster.redis.* anywhere in the repository, and
it has no caller. So the entire cluster: configuration block — 7 keys plus a 7-key
redis: sub-block — is unreachable on every code path a mount takes.
Third instance of the same shape as #156 (buildS3Config maps 6 of ~30 fields) and #176
(performance.read_ahead is validated and read by nothing): a setting accepted by every layer
that reads configuration and consulted by no layer that acts on it.
Evidence
The only reader (internal/cache/interface.go):
func NewFromConfig(cfg *config.Configuration) (types.Cache, error) {
if cfg.Cluster.Enabled && cfg.Cluster.Redis.Enabled {
return redis.NewCache(cfg.Cluster.Redis)
}
return NewMultiLevelCache(nil)
}$ grep -rn 'cache.NewFromConfig' --include='*.go' .
$ echo $?
1
What the mount path does instead (internal/adapter/adapter.go:125-143) — it builds a
MultiLevelConfig by hand and calls NewMultiLevelCache directly, never consulting
cfg.Cluster:
cacheConfig := &cache.MultiLevelConfig{
L1Config: &cache.L1Config{...},
L2Config: &cache.L2Config{...},
Policy: a.config.Cache.EvictionPolicy,
}
a.cache, err = cache.NewMultiLevelCache(cacheConfig)grep -rn '\.Cluster\.' --include='*.go' . returns three hits, all three inside
internal/cache/interface.go.
Note the second arm is also lossy in its own right: NewMultiLevelCache(nil) discards the
L1/L2 sizing, TTL, persistent-cache directory, and eviction policy the caller's config
carries. So even if it were called, the non-Redis path would ignore most of cache: too.
Why this matters more than an unused function
redis.NewCache verifies connectivity during construction, so this is not merely a knob that
does nothing — it is a knob whose failure mode is silence. A deployment that sets
cluster.enabled: true and cluster.redis.enabled: true gets an in-process cache with no
error, no warning, and no indication that its Redis is not being used. It will look correct
until two nodes disagree.
examples/config.yaml:193-196 currently states this in a comment, which is the honest
short-term answer but not a fix:
The Redis block is the one usable part, and it is reached only through
cache.NewFromConfig, which currently has no caller.
Options
- Call it.
Adapter.Startusescache.NewFromConfig(a.config), andNewFromConfig
builds theMultiLevelConfigfromcfg.Cacherather than passingnil. This makes the
Redis path reachable and fixes the second arm's lossiness at the same time. Requires
Adapter.cacheto be typed astypes.Cacherather than*cache.MultiLevelCache— worth
checking whether anything depends on the concrete type (a.cache.Clear()at
adapter.go:325is one such call;Clearis not ontypes.Cache). - Reject the config. If distributed mode is not ready to be reachable, make
Configuration.Validatefail oncluster.enabled: truewith a message saying so, rather
than accepting a setting that does nothing.
(1) is preferable. (2) is acceptable only as an interim, and is strictly better than the
status quo: a rejected config costs a minute, an ignored one lets an operator believe they
are running a shared cache.
Do not simply delete NewFromConfig — that removes the evidence without removing the
dead config surface, which is how this class of defect stays invisible.
Related
- C0-3: Plumb parallel-read and pool-size settings through buildS3Config #156 —
buildS3Configmaps 6 of ~30 fields - performance.read_ahead is validated, documented, and read by nothing #176 —
performance.read_aheadis read by nothing - A2-1: Wire ClusterManager into Adapter and FileSystem #139 — wiring
ClusterManagerinto the adapter; note that issue's premise is wrong in a way
that matters here, sinceconfig.ClusterConfiganddistributed.ClusterConfigare disjoint
types and the call it proposes is a type error - A3-3: Distributed mode config documentation and validation #152 — cluster config validation and docs, whose acceptance criteria name
persistent_log,
data_dir, andseeds; the schema has none of those (seed_nodes, and no other two)
Activity
test: hold the coverage gate's unfloored set to a recorded reason (#359)