-
Notifications
You must be signed in to change notification settings - Fork 339
feat(common): Add cross-process lock dirtying #5672
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
base: main
Are you sure you want to change the base?
Conversation
3c168ad to
976f768
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5672 +/- ##
==========================================
- Coverage 88.50% 88.49% -0.01%
==========================================
Files 360 360
Lines 100723 100819 +96
Branches 100723 100819 +96
==========================================
+ Hits 89145 89222 +77
- Misses 7395 7409 +14
- Partials 4183 4188 +5 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #5672 will not alter performanceComparing Summary
|
39b6f56 to
b29747d
Compare
891db14 to
985032c
Compare
f1d3407 to
9a87ac6
Compare
This patch adds `CrossProcessLockGeneration`. A lock generation is an integer incremented each time the lock is taken by another holder. If the generation changes, it means the lock is _dirtied_. This _dirtying_ aspect is going to be expanded in the next patches. This patch focuses on the introduction of this _generation_. The `CrossProcessLock::try_lock_once` method, and the `TryLock::try_lock` method, both returns a `Option<CrossProcessLockGeneration>` instead of a `bool`: `true` is replaced by `Some(_)`, `false` by `None`.
f2bd5ec to
1889f8c
Compare
…cache stores. This patch adds `Lease::generation` support in the crypto, media and event cache stores. For the crypto store, we add the new `lease_locks` object store/table. Previously, `Lease` was stored in `core`, but without any prefix, it's easy to overwrite another records, it's dangerous. The sad thing is that it's hard to delete the existing leases in `core` because the keys aren't known. See the comment in the code explaining the tradeoff. For media and event cache stores, the already existing `leases` object store/table is cleared so that we can change the format of `Lease` easily.
This patch detects when the cross-process lock has been dirtied. A new `CrossProcessLockResult` enum is introduced to simplify the returned value of `try_lock_once` and `spin_lock`. It flattens the previous `Result<Option<_>>` by providing 3 variants: `Clean`, `Dirty` and `Unobtained`.
1889f8c to
884d726
Compare
WIP