You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
Yes it does, but incrementing a counter makes it difficult to reset the
circuit breaker after a certain time, so I use a capped collection
containing documents with a `created_at` field. I insert one for every
failure and query for the number of them happened in the last X seconds,
opening the circuit breaker if they are more than a threshold.
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:
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.
The text was updated successfully, but these errors were encountered: