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

Optional optimistic locking #115

Closed
argaen opened this issue Jan 23, 2017 · 0 comments
Closed

Optional optimistic locking #115

argaen opened this issue Jan 23, 2017 · 0 comments
Labels
Milestone

Comments

@argaen
Copy link
Member

argaen commented Jan 23, 2017

In order to fix #95 and #27 there is a need of some locking mechanism for a given key. This way we can avoid race conditions and also queue up queries to database if we know there is already one query with the same key going on.

After some reading, optimistic locking looks like a good approach on this. We can let the client deal with the exception in case of a race condition. With this solution, we will still need an adhoc one for solving #27.

Solutions for each backend:

memcached

CAS token as suggested in #95 looks good. aiomcache seems it does not support it... will need to implement it there or send the command directly -> PR open aio-libs/aiomcache#33

redis

Use WATCH to reproduce the CAS token: https://redis.io/topics/transactions#optimistic-locking-using-check-and-set.

Need to find a way to reuse the same connection when using it. The granularity is by connection so if another one is used it won't work.

memory

EDIT: Ignore previous, its easier if we use the distributed lock that was used to implement Redlock. Straightforward use

@argaen argaen added the feature label Jan 23, 2017
@argaen argaen added this to the 0.4.0 milestone Jan 23, 2017
@argaen argaen changed the title locking mechanism for keys Optional optimistic locking Feb 1, 2017
@argaen argaen removed this from the 0.4.0 milestone Apr 14, 2017
@argaen argaen mentioned this issue Apr 17, 2017
3 tasks
@argaen argaen modified the milestone: 0.7.0 Jun 2, 2017
argaen added a commit that referenced this issue Jun 19, 2017
Optimistic locking implementation. Not available through public API
but its working for all three backends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant