Skip to content

cache.NewFromConfig has no caller, so the entire cluster/redis config block is unreachable #178

Closed

Description

@scttfrdmn

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

  1. Call it. Adapter.Start uses cache.NewFromConfig(a.config), and NewFromConfig
    builds the MultiLevelConfig from cfg.Cache rather than passing nil. This makes the
    Redis path reachable and fixes the second arm's lossiness at the same time. Requires
    Adapter.cache to be typed as types.Cache rather than *cache.MultiLevelCache — worth
    checking whether anything depends on the concrete type (a.cache.Clear() at
    adapter.go:325 is one such call; Clear is not on types.Cache).
  2. Reject the config. If distributed mode is not ready to be reachable, make
    Configuration.Validate fail on cluster.enabled: true with 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

Activity

  1. added
    type: bug
    priority: high
    area: cache
    area: config
    area: distributed
    on Aug 1, 2026
  2. added
    effort: medium
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cachearea: configarea: distributedeffort: mediumpriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions