-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set_result on canceled future #34
Comments
Thank you for this bug report. The problem is to know why the future was cancelled, but it shows that we need to check the futures more carefuly. Can you add more details on how you get this error ? The conditions ? |
Sure. I'm using aioamqp inside a web app to spawn background tasks in another machine. I create a new channel in each request and then I publish to an exchange, like this:
The issue comes when I do localhost ApacheBench tests with -n 10000 and -c 1000:
I think the -n and -c values will be different in each machine.
Regards |
Is there any interesting log in your amqp broker ? what does it says ? |
It's RabbitMQ. Nothing interesting there, only open/close connections. I have noticed that it does not happen every time (but apache bench always fails "apr_socket_recv: Connection reset by peer (104)"), so it seems that when the http server breaks the future is canceled and then occurs some kind of race condition. Perhaps it's not your fault and you only have to check future's state for graceful behavior when program breaks. |
I'll try something similar tomorow afternoon. Which asyncio http server are you using ? aiohttp.web ? |
Yes, it's aiohttp, with this minimal code fails too:
Exchanges and queues are created previously and are durable. |
This doesn't sound like abusing the protocol as the server gladly creates the new channels, but might be related to the error emerging. |
Hello, I used your script on my machine, I set index to be a coroutine, and added a yield from channel.close() in this coroutine. results: $ ab -n 10000 -c 1000 localhost:8080/ Benchmarking localhost (be patient) Server Software: Document Path: / Concurrency Level: 1000 Connection Times (ms) Percentage of the requests served within a certain time (ms) |
Arg, I forgot channel.close() but still fails, try it with higher numbers |
Hello again, I ran 'ab' with :
And got an error when decoding the frame:
I must check the doc to check the frame parsing. Can you test against the last master ? |
aioamqp cannot reuses previous channel id for now. I created issue #36 |
Last master keeps failing. Remember that it does not shows the error every time, it does after two or three tests. |
I'll retest this when the library would reuise the channel id |
I also encountered this. (Or at least I think I did.) I take it that fixing the problem is more complicated than just adding a check |
Here's a log where the problem occurs. It looks like
I think this might be occurring in a case where there's two attempts to close the channel. |
Hello @ariddell, would you please paste some ? it seems you already closed the channel ? |
I'm not doing anything sophisticated, just a simple RPC setup; no multi-threading just asyncio. If I do have two coroutines that both close the connection/channel there shouldn't be an error, right? I'll see if I can't figure out a way to reproduce the error. |
I have a few days to have a look right now. I can push a branch with a fix, but I would like to know how you're using aioamqp and how you're triggering this bug. Thank you |
I'm pretty sure I'm calling close on the connection and then close on a channel (associated with the connection). I know this is wrong but I think aioamqp might want to check on the future being cancelled. In case you're looking for prior art, here is how aiohttp closes a websocket -- They have a
|
Hello @ariddell. In aioamqp, the code is a little bit different: you get an exception in the code when receiving the confirmation from the server (https://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.close-ok) but the whole channel is already mark'd as closed. Could you please tell me how you're triggering this behaviour ? I'll dive into it and probably rework the way we're closing the channel. Thank you. |
I don't know how the exception is happening. I think it's something in a finally clause so it's not affecting my application. I'll keep you posted. Thanks for your work on this! |
The asyncio documentation says:
The text was updated successfully, but these errors were encountered: