[rabbitmq-discuss] java-client: Reproducable "COMMAND_INVALID - second 'channel.open' seen"
Tim Watson
tim at rabbitmq.com
Wed Mar 27 11:08:13 GMT 2013
Hi Victor,
Thanks for reporting this, and for providing a test case! I've filed a
bug to fix it and hopefully it'll be included in the next release.
Tim
On 03/27/2013 06:26 AM, Victor Boivie wrote:
> I have been having some problems with the java-rabbitmq-client when
> stress testing it. I frequently get "COMMAND_INVALID - second
> 'channel.open' seen", which eventually closes the connection (not just
> the channel).
>
> It seems that there is a race condition when channels are closed
> asynchronously (due to errors), and created in other threads. The
> channel that is closed (by the server) doesn't seem to be fully closed
> before another thread can try to open a channel with the same number.
>
> The code to reproduce it is at https://github.com/boivie/rmq-stress-test
>
> A possible fix is below.
>
> Thanks,
> Victor
>
> From 213cf8ef15a759985bc9dd74496548236b5160f2 Mon Sep 17 00:00:00 2001
> From: Victor Boivie <victor at boivie.com <mailto:victor at boivie.com>>
> Date: Wed, 27 Mar 2013 07:22:04 +0100
> Subject: [PATCH] Fix race-condition of asynchronously closed channels
>
> When a channel is closed from the server side due to errors we
> have to send CloseOk before we can make it available for allocation
> again. If not, we risk handing it out to a client which will open it
> when it's not yet fully closed, which results in a
> "COMMAND_INVALID - second 'channel.open' seen".
>
> diff --git a/src/com/rabbitmq/client/impl/ChannelN.java
> b/src/com/rabbitmq/client/impl/ChannelN.java
> index 18e4f6a..9fe11c3 100644
> --- a/src/com/rabbitmq/client/impl/ChannelN.java
> +++ b/src/com/rabbitmq/client/impl/ChannelN.java
> @@ -471,7 +471,6 @@ public class ChannelN extends AMQChannel
> implements com.rabbitmq.client.Channel
> }
> private void asyncShutdown(Command command) throws IOException {
> - releaseChannel();
> ShutdownSignalException signal = new
> ShutdownSignalException(false,
>
> false,
>
> command,
> @@ -484,6 +483,7 @@ public class ChannelN extends AMQChannel
> implements com.rabbitmq.client.Channel
> notifyOutstandingRpc(signal);
> }
> }
> + releaseChannel();
> notifyListeners();
> }
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130327/980b7140/attachment.htm>
More information about the rabbitmq-discuss
mailing list