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: avoid race condition when creating policies #102

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

LucianBuzzo
Copy link
Contributor

If you're trying to startup multiple Yates clients simultaneously, it's possible that you hit an error where on client tries to create a policy that the other client has already created.
This occurs because we read all abilities in one go. To avoid this, we check the ability table once per RLS policy, and we do it inside a transaction with a lock. This means that the second client will behave correctly and not try to create the policy again.

If you're trying to startup multiple Yates clients simultaneously, it's
possible that you hit an error where on client tries to create a policy
that the other client has already created.
This occurs because we read *all* abilities in one go. To avoid this, we
check the ability table once per RLS policy, and we do it inside
a transaction with a lock. This means that the second client will behave
correctly and not try to create the policy again.
@LucianBuzzo LucianBuzzo force-pushed the lucianbuzzo/create-policy-race-condition branch from b7b3b78 to 4d77dfb Compare April 9, 2024 16:23
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Published beta package version: 3.5.1-beta.dangerous.1486584

Copy link

sonarcloud bot commented Apr 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

@Sr-santi Sr-santi left a comment

Choose a reason for hiding this comment

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

I didn't know that we were using abilities and Policy tables

@LucianBuzzo LucianBuzzo merged commit ab3b28a into master Apr 10, 2024
7 checks passed
@LucianBuzzo LucianBuzzo deleted the lucianbuzzo/create-policy-race-condition branch April 10, 2024 10:06
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.

2 participants