-
Notifications
You must be signed in to change notification settings - Fork 32
🐛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
matusdrobuliak66
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.
Thanks for the effort 🥇
GitHK
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.
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
pcrespov
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.
Fantastic redesign! I left some suggestions and a warning regarding func.__name__.
|



What do these changes do?
In short
lock_contextis goneexclusivedecorator shall be used insteadexclusive_periodicdecorator 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_contextcontext manager is gone as it has an inherent flaw if the lock disappears from the Redis database for whatever reason it will not raiseexclusivedecorator was re-written without usinglock_contextand is now the de-factor way of protecting functions with a distributed lock. This is the way nowasyncio.Taskasyncio.Tasks! Thus proving difficult to cancel them.background_task.pymodule that now also provides a decoratorperiodicwhich wraps tenacity ownretrydecorator with some standard parametersasync_delayeddecorator towith_delayintoasync_utils.pylock_contextcontext manager withexclusivedecorator repo-wideexclusive_periodicdecoratorRelated issue/s
How to test
Dev-ops checklist