Erlang/OTP Forums

Author Message

<  RabbitMQ mailing list  ~  Fwd: More RabbitMQ Erlang client woes

0x6e6562
Posted: Thu May 08, 2008 9:23 pm Reply with quote
User Joined: 12 Jul 2007 Posts: 250
Begin forwarded message:
Quote:
From: "Edwin Fine" <emofine@gmail.com (emofine@gmail.com)>
Date: 8 May 2008 22:12:07 BST
To: "Ben Hood" <0x6e6562@gmail.com (0x6e6562@gmail.com)>
Subject: More RabbitMQ Erlang client woes



Hi Ben,

Sorry for the long email. Trying to get to the bottom of the problems. I have done a LOT more investigation into the Erlang network client, and I believe there are two related bugs, one in the client, and the other I don't know where, or perhaps I am abusing how AMQP is supposed to work.

Bug #1: rabbit_writer not shut down

The first (and easier) bug, which I have fixed eventually, is that every time you start a channel, the network client creates a rabbit_writer, but never shuts it down. Therefore, each channel that is created leaves behind a rabbit_writer process.
What happens is that in the handshake, the network driver starts a rabbit_writer on channel 0. I believe this is used for the connection itself. Its pid is stored in writer_pid in the connection_state. This writer gets cleaned up properly when the connection is shut down. There is no problem with this.
Thereafter, when a channel is opened and amqp_network_driver:open_channel is called, another writer is started (correctly - need one per connection, right?). There is a singleton reader. Anyway, this writer is never terminated. The writer is registered as a peer to the channel, using amqp_channel:register_direct_peer. This causes a bug, because the registered peer is never shut down, probably because the direct peer never should be shut down... but this is the NETWORK peer.

So what I did (and you may have a better way) is to add another function, amqp_channel:register_network_peer. This sets a "direct" flag in the channel_state (which I had to add) to false. Calling register_direct_peer sets the flag to true. When amqp_channel:channel_cleanup() is eventually called (and I had to do something for this, too), it checks to see if direct is false. If so, it stops the writer in writer_pid, otherwise it leaves it alone.

I also had to add a call to channel_cleanup in the close_ok, because the cleanup was never getting called.:

amqp_channel:handle_method(ChannelCloseOk = #'channel.close_ok'{}, State) ->
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum