- Notifications
You must be signed in to change notification settings - Fork1.1k
fix: serialize updateEntitlements()#14974
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
spikecurtis commentedOct 4, 2024
This stack of pull requests is managed by Graphite.Learn more about stacking. Join@spikecurtis and the rest of your teammates on |
Emyrk commentedOct 4, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just so I understand, and jotting notes as I break for a minute. I am going to play with this after some morning calls.
Is the issue that in the multiple calls in unit tests, the earlier calls do not have a license. This earlier call happens in parallel to the later call (with license). If the later one finishes first, then the earlier call overwrites it back to no license. The fix, is to force serialization such that the order of calls to This looks to be a good solution. The test does not exercise the bug when I remove the channel, but I only briefly looked at it atm. An aside. when I extracted this logic out into this package, I was not really happy with the API it exposed. But it was already used throughout the codebase, and refactoring it everywhere felt like a large lift. Since we only have 1 entitlement per coderd, it could probably be it's own go routine and take feature sets to merge into the existing. Ensuring everything is done in order if multiple threads are working with it. Order would matter still though, as there is no time information to know which |
spikecurtis commentedOct 4, 2024
Yeah, exactly.
Hard to hit the bug consistently, since it's a race over which one writes first. |
Emyrk left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hard to hit the bug consistently, since it's a race over which one writes first.
I figured it would be.
Theentitlements package I refactored out because I had to access it from theidpsync package, and there is an import loop ifentitlements is kept incoderd.
I think if done from scratch, the update code would look a lot different.
Regardless, I like this serialized approach.Modify can still get around this, but it's really useful for unit tests.
288df75 intomainUh oh!
There was an error while loading.Please reload this page.

Uh oh!
There was an error while loading.Please reload this page.
fixes#14961
Adding the license and updating entitlements is flaky, especially at the start of our
coderdenttesting because, while the actual modifications to theentitlements.Setwere threadsafe, we could have multiple goroutines reading from the database and writing to the set, so we could end up writing stale data.This enforces serialization on updates, so that if you modify the database and kick off an update, you know the state of the
Setis at least as fresh as your database update.