Skip to content
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

feat: Add redis locking strategy #169

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

gfyrag
Copy link
Contributor

@gfyrag gfyrag commented Mar 15, 2022

  • Add redis locking strategy.
  • Add TLS connection to redis.

This PR allow to configure the lock strategy used by the ledger to prevent concurrent transactions.
Following flag was defined :
* --lock-strategy: memory, none, or redis (default: memory)

The 'none' strategy disable locking. The client could handle the retry itself.
The 'memory' strategy is the default and is the same as before.
The 'redis' strategy use a lock on redis.

'redis' strategy use additionnal flags :
* --lock-strategy-redis-url: Url of the redis server
* --lock-strategy-redis-duration: Duration before redis remove the lock whatever the job is terminated or not (prevent deadlock if a service crash)
* --lock-strategy-redis-retry: It is the waiting duration between two attempts to get a lock (if already take by another transaction).
@gfyrag gfyrag requested a review from a team as a code owner March 15, 2022 13:03
@gfyrag gfyrag requested a review from altitude March 15, 2022 13:03
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #169 (a2ff841) into main (3020ef0) will increase coverage by 1.16%.
The diff coverage is 76.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #169      +/-   ##
==========================================
+ Coverage   72.83%   73.99%   +1.16%     
==========================================
  Files          76       76              
  Lines        3011     3096      +85     
==========================================
+ Hits         2193     2291      +98     
+ Misses        648      634      -14     
- Partials      170      171       +1     
Impacted Files Coverage Δ
pkg/ledger/lock.go 82.60% <0.00%> (-17.40%) ⬇️
pkg/opentelemetry/opentelemetrytraces/resource.go 100.00% <ø> (ø)
pkg/ledger/ledger.go 78.22% <33.33%> (+0.88%) ⬆️
pkg/redis/lock.go 61.22% <61.22%> (ø)
pkg/ledger/resolver.go 85.00% <70.00%> (-3.00%) ⬇️
cmd/container.go 81.89% <77.77%> (-0.76%) ⬇️
pkg/ledger/error.go 80.30% <80.00%> (-0.06%) ⬇️
pkg/redis/module.go 89.47% <89.47%> (ø)
pkg/opentelemetry/opentelemetrytraces/traces.go 82.10% <95.83%> (+3.72%) ⬆️
cmd/root.go 87.34% <100.00%> (+1.23%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b5a1c2...a2ff841. Read the comment docs.

@gfyrag gfyrag merged commit eaa39c4 into main Mar 15, 2022
@gfyrag gfyrag deleted the feature/num-344-ledger-backport-redis-lock-from-ledger branch March 15, 2022 21:13
flemzord pushed a commit that referenced this pull request Jun 7, 2023
flemzord pushed a commit that referenced this pull request Sep 20, 2023
flemzord pushed a commit that referenced this pull request Dec 4, 2023
flemzord pushed a commit that referenced this pull request Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants