perf(groundcontrol): implement in-memory cache for satellite group states - #619
perf(groundcontrol): implement in-memory cache for satellite group states#619ahsan-zamil wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 18 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
| Duplication | 3 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/groundcontrol/server/config_handlers.go">
<violation number="1" location="internal/groundcontrol/server/config_handlers.go:505">
P1: When a group membership transaction commits while this request fills a cache miss, this write can repopulate the entry after the mutation handler invalidates it. Later `SetSatelliteConfig` calls then reuse the pre-change group list; publish only if a cache-generation check still matches, or synchronize cache fills with invalidation.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } | ||
| groupStates = append(groupStates, utils.AssembleGroupState(grp.GroupName)) | ||
| } | ||
| s.setCachedGroupStates(sat.ID, groupStates) |
There was a problem hiding this comment.
P1: When a group membership transaction commits while this request fills a cache miss, this write can repopulate the entry after the mutation handler invalidates it. Later SetSatelliteConfig calls then reuse the pre-change group list; publish only if a cache-generation check still matches, or synchronize cache fills with invalidation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/groundcontrol/server/config_handlers.go, line 505:
<comment>When a group membership transaction commits while this request fills a cache miss, this write can repopulate the entry after the mutation handler invalidates it. Later `SetSatelliteConfig` calls then reuse the pre-change group list; publish only if a cache-generation check still matches, or synchronize cache fills with invalidation.</comment>
<file context>
@@ -475,31 +475,34 @@ func (s *Server) SetSatelliteConfig(w http.ResponseWriter, r *http.Request) {
+ }
+ groupStates = append(groupStates, utils.AssembleGroupState(grp.GroupName))
+ }
+ s.setCachedGroupStates(sat.ID, groupStates)
}
</file context>
…ates Signed-off-by: Ahsan Zamil <ahsanzamil76@gmail.com>
6096f78 to
661a0bd
Compare
This PR resolves #583 by implementing a thread-safe and nil-safe in-memory cache for satellite group states on the Ground Control
Serverstruct.Changes:
groupStateCachemap (map[int32][]string) and agroupStateCacheMusync.RWMutexto theServerstruct.SetSatelliteConfig()and populated it on a cache miss.DeleteSatelliteAddSatelliteToGroupRemoveSatelliteFromGroupDeleteGroup(clears the cache)group_cache_test.goverifying cache hits, lazy initialization, and invalidation.Closes #583