Responses mismatch requests resulting in ValueError being raised.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
txAMQP |
Invalid
|
Undecided
|
Unassigned |
Bug Description
The problem here is quite complex. I have been testing the following scenario.
1. Connect to RabbitMQ.
2. Open two channels (with id 1, 2).
3. For both channels perform the following operations:
Deferred chain I:
a) queue_declare durable=True (each channel uses different name)
b) basic_consume name=<matches the queue>, no_ack=False
c) queue consumer_
Deferred chain II:
a) exchange_declare type=direct nowait=False durable=True name='lobby' (same for both channels)
b) queue_bind nowait=False, exchange='lobby', queue=<matches queue for each channel>
Steps above basicly creates the setup for some more stuff I want to test. This usually works. But once for a while there is an exception raised inside the txamqp library. Please see the attached diff "fix" for details. The frequency of the failures is different depending on the machine speed. Also increasing number of channels makes the test fail more often. Unfortunately I cannot separate the failing testcase - it depends on rest of the project too much to share.
The problem requires some special timing: steb Ib) is waiting for response, but than the IIa) sends the request. Once upon a time the responses for the requests will get confused resulting in a crash.
You are probably thinking now 'just connect both deferred chains and stop bugging me!'. I have made such tests, and this fixes the problem at hand. But it will pop up later, I just don't want to synchronize all the action being performed on the channel.
I consider this a bug in txamqp.
Putting things simple: the design assumes that RabbitMQ sends responses to the channel in the same order the requests has been sent. This assumption is not met, the design should be updated.
I'm attaching the diff with the "fix" (citation marks denotes how dirty it is) I made to get the scenario working. The solution is far from perfect, please take a look at the inline comments.
Changed in txamqp: | |
status: | New → Invalid |
Hi,
I suffered from this problem too, but it happened to be a problem in the code calling txAMQP, not txAMQP itself. In section 2.2.1 of the AMQP 0.9.1 specification [1], methods are grouped in two classes: synchronous and asynchronous. Protocol methods that expect a response (e.g. Queue.declare, Exchange.delete, etc.) must be issued synchronously (i.e. wait for its response) and cannot be pipelined. That means that you'll have to synchronize your methods so that you don't issue a command before the response for the previous command has been processed.
In our case, this was caused by a missing "yield" in an inlineCallbacks decorated function. Given that you can't provide an isolated test, if you send me your code (it'll be treated confidentially), I can have a look at it.
Cheers.
1 - http:// www.amqp. org/confluence/ download/ attachments/ 720900/ amqp0-9- 1.pdf?version= 1&modificationD ate=12275265230 00