Skip to content

Fix concurrent map access in rbac#1844

Merged
timbastin merged 4 commits intomainfrom
fix-panic-in-sync
Apr 2, 2026
Merged

Fix concurrent map access in rbac#1844
timbastin merged 4 commits intomainfrom
fix-panic-in-sync

Conversation

@Hubtrick-Git
Copy link
Copy Markdown
Collaborator

When triggering the sync for an org, sometimes concurrent routine would cause a concurrent read write panic on the rbac models underlying map. TO prevent this I added a mutex and used lock/unlock guards around each call of the enforcer functions.

Copilot AI review requested due to automatic review settings April 2, 2026 14:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a runtime concurrent map read and map write panic observed during org sync by serializing access to the shared Casbin RBAC enforcer/model with a mutex.

Changes:

  • Introduces a package-level sync.RWMutex to guard concurrent access to Casbin’s shared RBAC structures.
  • Wraps Casbin enforcer read calls with RLock/RUnlock and mutating calls with Lock/Unlock.
  • Guards the watcher update callback (LoadPolicy) with the same mutex to prevent concurrent policy reload vs. enforcement operations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Hubtrick-Git and others added 3 commits April 2, 2026 17:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tim Bastin <38261809+timbastin@users.noreply.github.com>
@timbastin timbastin merged commit 54df8cf into main Apr 2, 2026
42 checks passed
@Hubtrick-Git Hubtrick-Git deleted the fix-panic-in-sync branch April 3, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants