-
Notifications
You must be signed in to change notification settings - Fork 924
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
ARTEMIS-5155 Send of AMQP large messages should close the LargeMessageReader before proceeding with the message delivery #5346
Conversation
f794cfd
to
15a6ae1
Compare
...l/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonAbstractReceiver.java
Outdated
Show resolved
Hide resolved
af465ea
to
f23e5ad
Compare
this change is reverting the offending change from c83ed89 As I said before, marking the LargeMessageReader as complete after the delivery of the message of the queue could cause the message body to go truncated, if a network failure happened between the delivery and the actual close of the message (aka race). I'm merging this PR now as this is clearly an issue and this fixes that issue. |
I changed it to draft, as we have been looking into why this change might have any effect, as it didnt seem to either myself or Tim that it should have the desired impact, and possibly pointed to a potential concurrency problem. Whilst moving this might indeed help adjust the behaviour to stop a test failing, it still isnt clear to either of us it is actually the correct change given the point the close is done. Tim may have found a related issue around the delivery handling offloading large messages to another thread. In short, we still need to look at this a bit closer before merging. |
@gemmellr I don't think this is a draft.. it's definitely fixing the issue.. it's a small issue.. last packet arrived for the message another thread detects a failure... removed the file consequence is an empty / truncated file |
@gemmellr all I'm fixing now is.. when closeCurrentReader is called, it's deleting the file... which is what I'm fixing.. if you want to improve other things in large message.. it's totally orthogonal to this.. this change is fixing the issue. |
We are saying it may have been wrong the way it was as well, so just putting it back that way is not necessarily correct. Still looking at it further. In the meantime, this has been this way for 8 months, lets look at it before merging rather than after. |
There is at least one race in the AMQPLargeMessageReader where the bytes being written to the large message file is done on a session thread and only when the message is complete is it submitted to the receiver via the connection thread. If a network error happens that causes the receiver to close its active reader (which deletes the large message file) and at the same time the processing of a large message is about to complete and schedule the 'onMessageComplete' call to process the read message the message will get processed after its file is deleted and be put onto the Queue as if it was valid resulting in a corrupted message. We need to reevaluate the logic and how we process AMQP large messages off the netty thread to better account for the chasing scenarios to ensure files are deleted but completed message still get processed as intended. |
I think the close should happen before onMessageComplete, on the caller thread. |
f23e5ad
to
68ad100
Compare
…eReader before proceeding with the message delivery This is fixing LargeMessageInterruptTest
68ad100
to
779f471
Compare
|
||
// messageReader.close should be called before the delivery, to signal the reader is complete. | ||
this.messageReader.close(); | ||
this.messageReader = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null assignment should remain in a finally block as it ensures that the reader is always nulled when onMessageComplete gets called.
I have closed this in favor of Tim's PR. |
This is fixing LargeMessageInterruptTest