-
Notifications
You must be signed in to change notification settings - Fork 84
ENG-1976: Support blocking on redis lock acquisition #6961
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (82.10%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## main #6961 +/- ##
==========================================
- Coverage 87.32% 82.10% -5.23%
==========================================
Files 525 525
Lines 34418 34458 +40
Branches 3960 3967 +7
==========================================
- Hits 30055 28291 -1764
- Misses 3500 5346 +1846
+ Partials 863 821 -42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile OverviewGreptile SummaryThis PR adds blocking lock acquisition support to the Key changes:
Observations:
Confidence Score: 5/5
Important Files ChangedFile Analysis
|
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.
2 files reviewed, no comments
src/fides/api/util/lock.py
Outdated
| @contextmanager | ||
| def redis_lock(lock_key: str, timeout: int) -> Generator[Lock | None, None, None]: | ||
| def redis_lock( | ||
| lock_key: str, timeout: int, blocking: bool = False, blocking_timeout: int = 0 |
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.
Why is blocking_timeout set to 0 by default instead of None, which is the default for Lock?
I'm asking because previously, when blocking was False, we didn't send a blocking_timeout at all (which is effectively the same as sending None, matching the default behavior of Lock).
Is the goal to preserve the original behavior, or do we specifically want blocking_timeout=0 now?
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.
yeah no good reason, i don't think this technically mattered but it did read strangely, so i adjusted to default to None in 8401e29!
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.
thanks for the close eye 👍
Ticket ENG-1976
Description Of Changes
Support blocking lock acquisition with our
redis_lockcontext manager, which allows callers to implement a 'blocking lock' with ablocking_timeoutthat can be specified.This is needed for https://github.com/ethyca/fidesplus/pull/2786, in which we want to gate monitor task queueing so that it can't happen concurrently across a cluster of webservers.
Code Changes
blockingandblocking_timeoutto ourredis_lockcontext manager, default toFalseand0to keep existing behavior as-isblocking_timeoutis providedSteps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works