Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lock less when syncing #988

Merged
merged 1 commit into from Apr 16, 2022
Merged

Conversation

johanneswuerbach
Copy link
Contributor

Lock the SyncedEnforcer only when replacing the model and not during the entire policy reload duration.

Fixes #987

@casbin-bot
Copy link
Member

@tangyang9464 @closetool @sagilio please review

@hsluoyz
Copy link
Member

hsluoyz commented Apr 14, 2022

@tangyang9464 plz review

// Wait for at least one sync
time.Sleep(time.Millisecond * 300)

testEnforceSync(t, e, "bob", "data2", "write", true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this as otherwise this test was also passing when the policy reloading failed.

@hsluoyz
Copy link
Member

hsluoyz commented Apr 14, 2022

@johanneswuerbach plz fix:

image

@johanneswuerbach
Copy link
Contributor Author

Thanks @hsluoyz, should be fixed now.

@hsluoyz
Copy link
Member

hsluoyz commented Apr 15, 2022

@tangyang9464 plz review

Copy link
Member

@tangyang9464 tangyang9464 left a comment

Choose a reason for hiding this comment

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

Some suggestions please check out

enforcer_synced.go Outdated Show resolved Hide resolved
enforcer_synced.go Outdated Show resolved Hide resolved
enforcer.go Outdated Show resolved Hide resolved
Copy link
Member

@tangyang9464 tangyang9464 left a comment

Choose a reason for hiding this comment

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

LGTM

@hsluoyz hsluoyz merged commit 756b994 into casbin:master Apr 16, 2022
@github-actions
Copy link

🎉 This PR is included in version 2.44.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@johanneswuerbach johanneswuerbach deleted the background-sync branch April 19, 2022 07:30
@johanneswuerbach johanneswuerbach restored the background-sync branch June 3, 2022 07:01
@johanneswuerbach johanneswuerbach deleted the background-sync branch June 3, 2022 07:01
johanneswuerbach added a commit to johanneswuerbach/casbin that referenced this pull request Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] StartAutoLoadPolicy locks the entire enforcer on every sync
4 participants