Apama 10.7.2 | Developing Apama Applications | Developing Apama Applications in EPL | Implementing Parallel Processing | How contexts affect other parts of your Apama application | Deadlock avoidance when parallel processing
 
Deadlock avoidance when parallel processing
Parallel processing in the correlator uses a message passing system. Each context has a fixed-size input queue for events (messages). A deadlock is possible when all of the following conditions are true:
*Context 1 is enqueuing an event to context 2.
*Context 2 is enqueuing an event to context 1.
*The input queues for context 1 and context 2 are both full.
In this situation, each context is blocked from further processing until the queue of the other context is no longer full. Neither context can process the next event on its input queue. Such a deadlock is not limited to two contexts but can occur with any number of contexts enqueuing events to each other.
The correlator avoids such a deadlock by detecting the potential for it to occur and then expanding input queues as needed. Also, the correlator logs a warning that a potential deadlock was detected. The correlator expands input queues only when not doing so causes a deadlock. The correlator does not expand input queues when one or more contexts are blocked from further processing while one or more contexts are processing as usual. However, it is still possible to create applications that result in out of memory errors or other kinds of deadlocks. Out of memory errors can result from requiring excessive expansion of input queues through the deadlock avoidance mechanism, or other means, such as creating a very large sequence.