adding locking for userset weight writes as it is on demand#514
adding locking for userset weight writes as it is on demand#514yissellokta merged 3 commits intomainfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds thread-safety to weighted graph userset weight mutations by introducing per-node and per-edge sync.RWMutex instances stored in global sync.Map caches, with helper functions to lazily retrieve mutexes and synchronization wrapping around weight-setting operations. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pkg/go/graph/weighted_graph_concurrent_test.go (1)
1-252: Concurrent tests are solid; consider minor cleanupsThe subtests cover several important patterns (disjoint keys, shared key, node+edge in parallel, interleaved read/write) and exercise the new locking paths well. This is a good level of stress for the
usersetWeightsbehavior.Two small, optional tweaks:
- In the verification loops (e.g., Lines 47–60, 86–99, 169–197, 229–238), you can fetch the mutex once per loop, outside the inner body, to avoid repeated
sync.Maplookups viagetUsersetNodeMutex/getUsersetEdgeMutex.- Since all subtests share the same
node/edge, keep in mind future additions: if a new subtest depends on a “clean” state, it may need to reset or use a fresh graph. Right now the keys are disjoint enough that there’s no interference.These are purely polish; the tests as written are functionally fine.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/go/graph/weighted_graph.go(3 hunks)pkg/go/graph/weighted_graph_concurrent_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
pkg/go/graph/weighted_graph.go (2)
pkg/go/graph/weighted_graph_node.go (1)
WeightedAuthorizationModelNode(18-27)pkg/go/graph/weighted_graph_edge.go (1)
WeightedAuthorizationModelEdge(58-76)
pkg/go/graph/weighted_graph_concurrent_test.go (3)
pkg/go/graph/weighted_graph.go (1)
NewWeightedAuthorizationModelGraph(56-61)pkg/go/graph/weighted_graph_node.go (1)
SpecificTypeAndRelation(7-7)pkg/go/graph/weighted_graph_edge.go (2)
DirectEdge(11-11)NoCond(55-55)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
Description
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
mainSummary by CodeRabbit
Release Notes
Tests
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.