-
Notifications
You must be signed in to change notification settings - Fork 29
🐛Redis locks disappearing and fixup weird usage #7020
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
🐛Redis locks disappearing and fixup weird usage #7020
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7020 +/- ##
==========================================
- Coverage 86.94% 86.31% -0.63%
==========================================
Files 1651 1615 -36
Lines 64811 63147 -1664
Branches 2041 2043 +2
==========================================
- Hits 56351 54507 -1844
- Misses 8122 8305 +183
+ Partials 338 335 -3
Continue to review full report in Codecov by Sentry.
|
1d6a299
to
cd8df19
Compare
7563c97
to
9759786
Compare
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 effort 🥇
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.
Very nice! Thanks for looking into this annoying issue.
packages/service-library/src/servicelib/background_task_utils.py
Outdated
Show resolved
Hide resolved
ececacd
to
746fffb
Compare
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.
Fantastic redesign! I left some suggestions and a warning regarding func.__name__
.
|
What do these changes do?
In short
lock_context
is goneexclusive
decorator shall be used insteadexclusive_periodic
decorator is now the solution when one wants a background task that runs exclusively on one replica of a service, with automatic recovery in case the replica is stopped/crashed.Details
lock_context
context manager is gone as it has an inherent flaw if the lock disappears from the Redis database for whatever reason it will not raiseexclusive
decorator was re-written without usinglock_context
and is now the de-factor way of protecting functions with a distributed lock. This is the way nowasyncio.Task
asyncio.Task
s! Thus proving difficult to cancel them.background_task.py
module that now also provides a decoratorperiodic
which wraps tenacity ownretry
decorator with some standard parametersasync_delayed
decorator towith_delay
intoasync_utils.py
lock_context
context manager withexclusive
decorator repo-wideexclusive_periodic
decoratorRelated issue/s
How to test
Dev-ops checklist