[Backend] RedisClusterState derived projections re-filter+re-allocate on every access (SonarQube S2365 x3) #652

Closed
opened 2026-07-17 14:12:42 +00:00 by spikerj · 1 comment
Owner

From continued SonarQube triage (2026-07-17), after re-auditing on the fresh baseline. RedisClusterState.{Ghosts,Survivors,ConnectedMasters} were expression-bodied => Nodes.Where(...).ToList(), allocating a fresh filtered list on each read. Not a correctness bug — Nodes is init-only/immutable so results are stable, and no caller depends on referential identity (verified: all usages are .Count/.Select/.Single/.FirstOrDefault). But it is a real minor inefficiency: RedisClusterProbe reads Ghosts 4x in one alert path, each re-running the filter. Fixed by lazy-caching each into a backing field (materialize once); zero behavior/API change, SystemRemediation tests 82/82. PR incoming; will close on merge.

From continued SonarQube triage (2026-07-17), after re-auditing on the fresh baseline. `RedisClusterState.{Ghosts,Survivors,ConnectedMasters}` were expression-bodied `=> Nodes.Where(...).ToList()`, allocating a fresh filtered list on each read. Not a correctness bug — Nodes is init-only/immutable so results are stable, and no caller depends on referential identity (verified: all usages are .Count/.Select/.Single/.FirstOrDefault). But it is a real minor inefficiency: RedisClusterProbe reads Ghosts 4x in one alert path, each re-running the filter. Fixed by lazy-caching each into a backing field (materialize once); zero behavior/API change, SystemRemediation tests 82/82. PR incoming; will close on merge.
Author
Owner

Verified fixed on master — closing. (Ticket-triage loop 2026-07-18.)

Shipped in commit a3e59a5d perf(redis-heal): cache RedisClusterState's derived node projections (S2365) / PR #358 — the commit cited #649 (shifted-ref pattern, same as #656/#657), so this stayed open. Current master has Ghosts/Survivors/ConnectedMasters lazy-cached into backing fields (_ghosts ??= …) exactly as this ticket prescribed. SystemRemediation tests green. No code change required.

**Verified fixed on master — closing.** (Ticket-triage loop 2026-07-18.) Shipped in commit `a3e59a5d` *perf(redis-heal): cache RedisClusterState's derived node projections (S2365)* / PR #358 — the commit cited **#649** (shifted-ref pattern, same as #656/#657), so this stayed open. Current master has `Ghosts`/`Survivors`/`ConnectedMasters` lazy-cached into backing fields (`_ghosts ??= …`) exactly as this ticket prescribed. SystemRemediation tests green. No code change required.
Sign in to join this conversation.