I've built a behavior in erlang to subscribe to a given topic exchange and farm out message handling. I'm using the rabbitmq amqp_client library for erlang and when I put the system under heavy load I get, on occasion, the following error:<div>
<br></div><div><div>=ERROR REPORT==== 29-Jun-2011::18:02:18 ===</div><div>** Generic server <0.1117.0> terminating </div><div>** Last message in was {'$gen_cast',</div><div> {method,</div>
<div> {'channel.close',406,</div><div> <<"PRECONDITION_FAILED - unknown delivery tag 856">>,</div><div> 60,80},</div>
<div> none}}</div><div>** When Server state == {state,1,<0.1116.0>,network,</div><div> {[],[]},</div><div> {[],[]},</div><div>
{dict,0,16,16,8,80,48,</div><div> {[],[],[],[],[],[],[],[],[],[],[],[],[],</div><div> [],[],[]},</div><div> {{[],[],[],[],[],[],[],[],[],[],[],[],[],</div>
<div> [],[],[]}}},</div><div> false,<0.1118.0>,none,none,0,true,none,</div><div> {dict,1,16,16,8,80,48,</div><div> {[],[],[],[],[],[],[],[],[],[],[],[],[],</div>
<div> [],[],[]},</div><div> {{[[<<"amq.ctag-1sViVE9Y/wIKyAliWqjeCA==">>|</div><div> etl_dispatch]],</div>
<div> [],[],[],[],[],[],[],[],[],[],[],[],[],</div><div> [],[]}}},</div><div> none,#Fun<amqp_channel_sup.1.53915388>}</div>
<div>** Reason for termination == </div><div>** {server_initiated_close,406,</div><div> <<"PRECONDITION_FAILED - unknown delivery tag 856">>}</div></div><div><br></div><div>
The server receive loop where the ack happens looks like this:</div><div>receive</div><div>...</div><div><div>{#'basic.deliver'{delivery_tag = Tag, routing_key = RoutingKey}, #amqp_msg{payload = Payload}} -></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> amqp_channel:cast(get(amqp_channel_pid), #'basic.ack'{delivery_tag = Tag}),</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> spawn_and_queue(spawn_handle_message, Module, RoutingKey, Payload),</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> loop(Module);</div></div><div>...</div><div>end</div><div><br></div><div>The amqp_client_sup can't seem to bring back the the client either and dies from the retry intensity being reached. I've done a hefty amount of googling and can't seem to find where things could be going wrong. Before jumping into the amqp_client code I thought I'd ask the mailing list if they have any ideas. The only thing I can think is that there is a race condition within the client library. I will be double checking my code to be sure it isn't sending the ack twice, but given the simplicity of the ack the only way it could is if it receives the same message (with identical delivery tag) from the amqp_client library twice.</div>
<div><br></div><div>Thanks,</div><div>-Max</div>