[rabbitmq-discuss] Stuck waiting for frame during amqp_basic_qos?

Pieter de Zwart pdezwart at rubiconproject.com
Tue Nov 8 22:01:25 GMT 2011


Hey David,

Thanks for the pointer. I fixed that particular item, but as predicted, it
did not resolve the issue. With a fresh perspective I dug in some more,
and figured out that the culprit was calling amqp_basic_ack when no
message was consumed. Somehow that created the situation whereby the next
call to amqp_basic_qos got stuck.

If I write some very basic C code that replicates this behavior à la
rabbitmq-c/examples, do you think you can help me figure out what the hell
im doing wrong? =)

me




On 11/8/11 4:45 AM, "David Wragg" <david at rabbitmq.com> wrote:

>Hi Pieter,
>
>Pieter de Zwart <pdezwart at rubiconproject.com> writes:
>> I am doing something wrong, and I could use some help.  I
>> maintain/develop the PHP extension that interfaces with RabbitMQ via
>> the rabbitmq-c library. We have implemented all of the low level
>> calls, but have also added some helpful wrappers to let poor PHP users
>> not have to deal with all the complexity of the protocol. One of these
>> wrapper methods is AMQPQueue::getMessages(). Unfortunately, I have
>> built a bug I don¹t know how to squash.
>>
>> During the second call to the AMQPQueue::getMessages() function within
>> a loop (reusing connection and channel), the process get stuck in busy
>> wait. In the attached file on line 37, we call amqp_basic_qos() to
>> prevent any prefetching by the server. That call goes through the
>> following stack in rabbitmq-c:
>>
>> librabbitmq/amqp_framing.c:1999: amqp_basic_qos
>> librabbitmq/amqp_socket.c:356: amqp_simple_rpc_decoded
>> librabbitmq/amqp_socket.c:264: amqp_simple_rpc
>> librabbitmq/amqp_socket.c:157: wait_frame_inner
>>
>> And then it gets stuck in that while(1) loop.
>
>Nothing stands out as being obviously wrong in your code (I do notice
>one issue, but it is not responsible for the problem you describe).
>
>If you think you can guide a PHP newbie through how to trigger the
>problem within PHP, I'd be happy to try.
>
>Here is the issue I mentioned:
>
>> 	/* Set the QOS for this channel to match the max_messages */
>> 	amqp_basic_qos(
>> 		connection->connection_resource->connection_state,
>> 		channel->channel_id,
>> 		0,						/* prefetch window size */
>> 		0,						/* prefetch message count */
>> 		0						/* global flag */
>> 	);
>
>The AMQP terminology here is a bit confusing.  Setting the prefetch
>count to 0 does not mean "no prefetch".  The prefetch count represents a
>limit on the number of unacked messages for the channel/connection.
>Actually setting it to zero wouldn't make sense, as the server would not
>be able to deliver any messages to the client.  So a prefetch count of
>zero is specified to mean "no limit".
>
>Instead, you should set the prefetch count to one, meaning "allow me to
>have one unacked message, but no more".  In other words, no messages are
>prefetched.
>
>The prefetch size should be left as zero, because you don't want to
>limit that.
>
>David
>
>-- 
>David Wragg
>Staff Engineer, RabbitMQ
>VMware, Inc.



More information about the rabbitmq-discuss mailing list