Closed SpComb closed 7 years ago
The Condition race may have been fixed in 2ce7537 by getting rid of the unorthodox ruby Mutex, and using sync Actor methods for the operations instead.
Still worth figuring out how the Celluloid mailbox operations behave, if there's some more efficient way to implement the same primitive.
The current Observable API seems to behave correctly as designed now.
The
Kontena::Observable
class is used to share the continuously updatedDocker::State
between multiple service actors, using a singleDocker::Actor
to maintain theDocker::State
across crashes/restarts of both the Docker and Service actor crashes.This means that the observable state must be concurrency-safe across multiple actors. The current implementation uses a
Celluloid::Condition
variable to provide a neat synchronous API:Unfortunately the
Celluloid::Condition
variable lacks integration with any kind of mutex/semaphore, and that leads to race conditions typically solved using a combined mutex + condition variable approach: Ruby core ConditionVariableThe correct approach would probably be to make each
Observable
a separate Actor responsible for synchronizing the shared state. The question is, how to implement the current API, yielding to a receiver block on updates.