casbin / Casbin.NET

An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
https://casbin.org
Apache License 2.0
1.13k stars 110 forks source link

fix: concurrent access issues with HashSet<string> #361

Open seanamorosoamtote opened 3 weeks ago

seanamorosoamtote commented 3 weeks ago

Came across issues that are similar to https://github.com/casbin/Casbin.NET/issues/336

Was able to create a concurrent update of the grouping policy which would trigger concurrent access errors. It would work OK with only 100, but once you hit 500 or greater it would fail almost 100% of the time.

I don't think this should go into master as-is, but one of your members can take what is here and make the appropriate changes to handle the access. You can remove my code changes and just use the test and models to see the test fail.

casbin-bot commented 3 weeks ago

@sagilio please review

CLAassistant commented 3 weeks ago

CLA assistant check
All committers have signed the CLA.

sagilio commented 3 weeks ago

Thank you, I will try to reproduce the test failure scenario. The changes currently appear to be effective and correct, I think there might not be much need for further modifications.

hsluoyz commented 2 weeks ago

@seanamorosoamtote plz sign CLA:

image