[rabbitmq-discuss] .NET Client Connection.CreateModel Possible Deadlock / Not Thread Safe?

Chris Haines cjbhaines at gmail.com
Tue May 14 17:56:42 BST 2013


Hi All,

Server version: 3.0.4
.NET client version: 3.0.4

I have had a problem on my Production servers this week where it looks like 
the call to CreateModel on IConnection is not thread safe, despite the 
documentation indicating that the entire IConnection should be thread safe. 
My application runs a single shared connection with somewhere in the region 
of 200-400 threads which will be creating models for at least 1 consumer 
and many publishers per thread. It looks like we had a small 
network hiccup and the connection reset, prompting all of the 
publishers/consumers to request new models at the same time. There is a 
very high chance that there will be threading clashes in this circumstance. 
The symptom after a threading clash is that all current requests for 
Connection.CreateModel() will throw an exception with the following error:

RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP 
operation was interrupted: AMQP close-reason, initiated by Peer, code=503, 
text="COMMAND_INVALID - second 'channel.open' seen", classId=20, 
methodId=10, cause=

And any subsequent requests to IConnection.CreateModel() on that connection 
instance indefinitely hang. I have managed to resolve this for now by 
adding locking around channel creation.

I have attached an NUnit test file which recreates this problem. The test 
case that uses locking will pass and the test without locking will 
indefinitely hang after it tries to create a channel on line 62 (at which 
point all of the threads are now hanging requesting a model).

Has anyone seen any problems like this before?

Cheers,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130514/124cd32f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MultiThreadedChannelCreationTest.cs
Type: text/x-csharp
Size: 3634 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130514/124cd32f/attachment.bin>


More information about the rabbitmq-discuss mailing list