Deadlock in messaging system error



The application is multi-threaded with the threads communicating via messaging (SEND, RECEIVE).  After running for a certain period of time the application halts and the Runtime reports "Deadlock in messaging system".


The deadlock message appears in two scenarios:

1. Two threads are waiting for messages from each other.

2. All threads are waiting, either for messages or for space in the message queue.

The message queue is dynamically resized, as needed, to hold large messages. However, it is not resized to hold multiple messages (instead, the sending threads wait until the queue empties).  

It is likely that messages are being sent by one thread but are never received by another.  Perhaps threads are stopping without processing their messages, stranding those messages in the queue.  When this happens, the message queue eventually fills up and messages can no longer be sent until the queue empties.  If no other thread reads messages out of the queue, the result is a deadlock.  

Adding code to receive all messages before the thread stops should resolve the issue.

Setting MESSAGE-QUEUE-SIZE larger than the default of 1024, up to the maximum of 32767, may also alleviate the error.  However, it may simply delay the error as the queue will still be filling up.

Old KB# 3191
Comment List