[rabbitmq-discuss] erlang client API: transactions

Edwin Fine rabbitmq-discuss_efine at usa.net
Tue Sep 23 22:36:36 BST 2008


Thanks, Ben. I'll apply the patch.

Incidentally this is the only part of the entire Erlang Rabbit code base
that uses queue:head/1 :)

I'm glad that I was not hallucinating; I was so tired when I looked at that
code the screen was getting blurred...

Ironically, I looked suspiciously at the use of cast in the code, but then I
thought, why not be able to cast? I thought wrong.

Edwin

On Tue, Sep 23, 2008 at 7:49 AM, Ben Hood <0x6e6562 at gmail.com> wrote:

> Edwin,
>
> On Tue, Sep 23, 2008 at 5:49 AM, Edwin Fine
> <rabbitmq-discuss_efine at usa.net> wrote:
> > I believe this is coming from the Erlang client, in
> > amqp_channel:rpc_bottom_half/2. I can't tell you why your program is
> doing
> > this, only where the error message originates. It seems to be happening
> in
> > response to receiving a tx.select_ok, AFAICS.
> >
> > If you look at the code for rpc_bottom_half (reproduced at the end of
> this
> > email for convenience), the line
> >
> > {{value, {From,_}}, NewRequestQueue} = queue:out(RequestQueue)
> >
> > will create the error message you are seeing if RequestQueue is empty.
> This
> > can clearly be seen in the shell:
> >
> > 1> EmptyQ = queue:new().
> > {[],[]}
> > 2> {{value, {From,_}}, NewRequestQueue} = queue:out(EmptyQ).
> > ** exception error: no match of right hand side value {empty,{[],[]}}
> >
> > I don't know if this is a bug or one of those "can't happen" things that
> > just didn't give a nice error message. I suspect the latter, because the
> > code just cannot continue without the value of "From" to send a reply to.
> > Why should the function have been called with a reply if the reply queue
> is
> > empty? Something's wrong somewhere.
> >
> > In addition, maybe I am too tired to see straight, but this looks really
> > suspect:
> >
> >     catch case queue:head(NewRequestQueue) of
> >         empty ->
> >             ok;
> >         {NewFrom,Method} ->
> >             Do2(Writer,Method)
> >     end,
> >
> > This is because queue:head/1 exits when it is empty and does not return
> > 'empty', so the catch will return an EXIT:
> >
> > 1> catch queue:head(queue:new()).
> > {'EXIT',{empty,[{queue,head,[{[],[]}]},
> >                 {erl_eval,do_apply,5},
> >                 {erl_eval,expr,5},
> >                 {shell,exprs,6},
> >                 {shell,eval_exprs,6},
> >                 {shell,eval_loop,3}]}}
> >
> > I think this should be
> >
> >     catch case queue:head(NewRequestQueue) of
> >         {'EXIT', {empty,_}} ->
> >             ok;
> >         {NewFrom,Method} ->
> >             Do2(Writer,Method)
> >     end,
> >
>
> Thanks for pointing this one out - it was a branch of the code that
> had never been visited by any tests before :-(
>
> I've applied this patch to the client - see
> http://hg.rabbitmq.com/rabbitmq-erlang-client/rev/ef7db7bfc51a
>
> Currently it is only on that branch - this will be merged back into
> the mainline when the peer QA is done.
>
> Note that this is not the solution for the TX issue - that will be
> addressed separately.
>
> Ben
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080923/8561836e/attachment.htm 


More information about the rabbitmq-discuss mailing list