Skip to content

cluster.redis's pub/sub Invalidator is never started, so a Redis cache is shared but never invalidated #377

Closed

Description

@scttfrdmn

internal/cache/redis.Invalidator implements cross-node cache invalidation over Redis pub/sub: Publish broadcasts "<nodeID>:<key>", Subscribe runs a goroutine that deletes the key locally and skips the node's own broadcasts. It is tested, including the self-skip case.

NewInvalidator has no caller outside invalidation_test.go. Grepping NewInvalidator|\.Publish\(|\.Subscribe\( across internal/, cmd/, and pkg/ finds only the definition itself and an unrelated statusTracker.Subscribe in internal/fuse/mount.go.

The Cache is wired — internal/cache/interface.go:48 constructs it when cluster.enabled && cluster.redis.enabled. So the shipped behaviour is: nodes share a Redis cache, no node ever publishes an invalidation, and no node ever subscribes. The mechanism that exists to keep them consistent is inert.

How much this matters depends on a question worth settling explicitly, because the answer decides whether this is a bug or a deletion:

If the Redis cache is genuinely shared — all nodes reading and writing the same keyspace — then pub/sub invalidation is largely redundant. A DEL by one node is immediately visible to all of them, because there is one copy. In that case Invalidator is solving a problem this architecture does not have, and the honest fix is to delete it rather than wire it.

If nodes also hold a local L1 in front of Redis, invalidation is necessary and its absence is a stale-read bug. internal/cache/multilevel.go exists, so this is not hypothetical, but I have not traced whether any configuration puts a local tier in front of the Redis tier.

Either way the current state is wrong: a tested, exported, documented mechanism that nothing starts. Resolve by wiring it (and testing that a two-node configuration actually invalidates) or by deleting it and saying in the package doc why a shared keyspace does not need it.

Related: Cache.Delete cannot take a context, since types.Cache assigns none to any method. Cache.DeleteContext was added for the subscriber path in #179's contextcheck work — if Invalidator is deleted, that method loses its only caller and should go with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cachearea: distributedpriority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions