perf(server): invalidate planStats cache on node link/unlink#17
Open
Sentinel-Bluebuilder wants to merge 1 commit into
Open
perf(server): invalidate planStats cache on node link/unlink#17Sentinel-Bluebuilder wants to merge 1 commit into
Sentinel-Bluebuilder wants to merge 1 commit into
Conversation
getPlanStats caches `planStats:<planId>:<operator>` for 120s — this drives the totalNodes / totalSubscriptions counts on the plan card. After a link/unlink the cached count stayed stale for the full TTL, so the card never reflected the just-added (or removed) node until the cache expired. Add invalidatePlanStats(planId) and call it on every success path of the four node-mutation routes: - link (link-only retry + bundled lease+link) - batch-link (links-only retry + bundled) - unlink - batch-unlink cacheInvalidate is an EXACT-key delete and each route already knows both planId and getAddr(), so the operator-scoped key is reconstructed directly with no prefix tracking. The next /api/my-plans re-queries chain truth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getPlanStatscachesplanStats:<planId>:<operator>for 120s — this is what drives the totalNodes / totalSubscriptions counts on the plan card. After a link/unlink the cached count stayed stale for the full TTL, so the card never reflected the just-added (or removed) node until the cache expired.Fix
Add
invalidatePlanStats(planId)and call it on every success path of the four node-mutation routes:POST /api/plan-manager/linkPOST /api/plan-manager/batch-linkPOST /api/plan-manager/unlinkPOST /api/plan-manager/batch-unlinkcacheInvalidateis an EXACT-key delete, and each route already knows bothplanIdandgetAddr(), so the operator-scoped key is reconstructed directly — no prefix tracking needed. The next/api/my-plansre-queries chain truth.Notes
node --checkpasses. No non-ASCII edits.planNodes:at the same four call sites; this adds theplanStats:sibling. Kept as its own PR per the working-tree split.PR series
Fifth of the working-tree split: #13 (audit), #14 (plan-nodes cache), #15 (FE reconcile), #16 (gas/sessions cache), this (planStats invalidation).