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

Storage does not support atomic operations #1

Open
giorgiosironi opened this issue Jun 11, 2014 · 3 comments
Open

Storage does not support atomic operations #1

giorgiosironi opened this issue Jun 11, 2014 · 3 comments

Comments

@giorgiosironi
Copy link

The interface for storage:
https://github.com/ejsmont-artur/php-circuit-breaker/blob/master/src/Ejsmont/CircuitBreaker/Storage/StorageInterface.php
seems not to support atomic operations. Multiple processes on the same machine can interleave like:

1. load value X
2. load value X
1. store value X+1
2. store value X+1

so that X+1 is stored instead of X+2 due to this race condition. Are you aware of this? I was planning to integrate a MongoDB storage but with this interface it won't solve the problem.

@sdepablos
Copy link

It would be as easy as to implement a lock that is removed at the end of the operation. The good thing is that working with APC / memcache / Redis / Mongo it would be possible to expire the lock automatically after some time is something goes wrong.

@jeff-minard-ck
Copy link

apc, memcache, and redis all support increment/decrement operations which would be a much safer and performant option than custom locks. A quick look says that even mongodb supports some kind of increment too.

@giorgiosironi
Copy link
Author

giorgiosironi commented Feb 17, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants