-
Notifications
You must be signed in to change notification settings - Fork 55
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
ERROR: corrupted messages continues on 2.0.1 #211
Comments
After further investigation I noticed that message is malformed before publish it in the queue, so it seems that rabbitmq client does not have any relation with the issue. Something weird occurs here: Microsoft.Azure.WebJobs.Extensions.RabbitMQ.RabbitMQListener
After TryExecuteAsync execution, ea.Body comes corrupted. |
Exactly @M3LiNdRu . We have tested as far as we could introducing debugging lines in RabbitMQListener and we saw the same as you mention. |
Sorry, I have been busy this week on a Microsoft Hackathon project. As per my testing (the details are there in the other issue), I found the corruption to have happened out of the extension code. I could not reproduce the issue after upgrading to the latest client library with repeated testing. I had done another round of testing before creating release 2.0.1. I will try to come back to this tomorrow if time permits. |
Hello @JatinSanghvi . I've just created a PR (#212) that solves the issue. It is a workaround, but it works. Please, give it some time when you can. Thanks! |
Apologies due to error on my part. I used a string of length 8192 characters for testing. It seems the issue never reproduces for strings of lengths that are multiple of 512 bytes. I am not clear on why the message string was found corrupted only after receiving it the next time. I will go through @M3LiNdRu's message, try to debug the issue inside WebJobs SDK code, and appropriately will approve the associated PR if it looks like a correct fix or workaround for the issue. I will update my findings as I have them on this GitHub issue. |
I am having a different observation which matches with what I had during initial testing. I wrapped the call to this.logger.LogCritical($"RepublishMessages (1): {ea.Body.Span[0]}");
this.rabbitMQModel.BasicPublish(exchange: string.Empty, routingKey: this.queueName, basicProperties: ea.BasicProperties, body: ea.Body);
this.logger.LogCritical($"RepublishMessages (2): {ea.Body.Span[0]}");
this.rabbitMQModel.BasicAck(ea.DeliveryTag, false); // Manually ACK'ing, but ack after resend
this.logger.LogCritical($"RepublishMessages (3): {ea.Body.Span[0]}"); This intermittently produces following output:
This means the client is updating the body before sending it back to RabbitMQ queue (as we can see the corruption). From next time onwards, the listener to |
I think I have understood the reason for the observation above. The call to The comment in RabbitMQ client source code here about requiring the handers to copy the delivery body partially points to this happening. Looking into the entire source code of the client should have cleared all doubts. This explains the corrupted message while logging in the end of previous invocation but does not explain the corruption in future invocations. I guess the |
Hi @JatinSanghvi, great to see that you've found a solution. When do you expect to release it? |
This is scheduled for Thursday this week. The release needs to be approved and the approvers are on vacation :) |
We have released version 2.0.2 that should have this issue fixed. Thanks to everyone on this issue thread. |
@JatinSanghvi We have updated to v2.0.2 but we still have an issue with corrupted request bodies. The error isn't always the same. We initially send a json object of type
|
Hi @tijmenamsing, if possible, can you share a function that will reproduce the error? |
I've traced this down to being caused by a combination of how the RabbitMQ client manages the memory of the body that gets passed in to the The RabbitMQ client (in The problem can be fixed by creating a copy of This is somewhat of a concurrency problem, so to reproduce it, the Azure Function needs to be sent multiple messages at once. Using only one message will not (or almost never) cause memory corruption. Edit: |
Hi @yvanoers, this is a great finding. I had actually made a change similar to what you suggested to be committed to be on the safer side as part of refactoring listener class, though I did not know that async is at play here. If possible, please have a check on the highlighted lines there and let me know if you think that should fix the issue. EDIT: The comment needs to be corrected there. |
Hi @JatinSanghvi, The same can be said for I would suggest using a local variable to hold the copy of |
@JatinSanghvi |
I should get the new release out in a day. |
The new version is released now. Thanks everyone for your help and support towards getting the issue fixed. |
It seems that The |
That looks like the intended way - it should be the actual fix. |
Hello.
The problem described in #207 still occurs. I have tested the same dummy function with the version 2.0.1 and I still see corrupted messages.
I have tested it over Function Host 4.1.1 and 4.11.0 with no difference.
The text was updated successfully, but these errors were encountered: