HandleCurrentMessageLater on workers causes workers to send extra ready messages
Hi!
Unfortunately we've found another bug with the distributor.
When you use HandleCurrentMessageLater() in a message handler on a worker, a ready message is sent back to the distributor when the message handler completes, even though the message is just put back on the local queue on the worker. This makes the storage on the distributor grow erroneously by 1 for every time you do a HandleCurrentMessageLater(). This can generate a lot of messages on the distributors control and/or storage queues quickly if you have a single message on your queue that you need to handle at a later time.
This is related to issue #571 and #806 as functionality working in a non-distributor scenario suddenly breaks when you scale out. Maybe a code review of all functionality in a distributor scenario is called for?
How to reproduce:
Extend the ScaleOut sample by changing ProcessOrderCommandHandler to do a HandleCurrentMessageLater(). Start solution and send an order.
Expected behaviour:
Worker doing HandleCurrentMessageLater() should EITHER
a) put the message back on the distributor input queue AND send a ready message to the distributor control queue OR b) put the message back on the local queue and NOT send ready messages back to the distributor.
Observed behaviour:
Message is put on local queue AND ready message is sent to distributor.control order.handler.distributor.storage increases unbounded as quickly as the infrastructure can write the message back on the local queue and read it again.
Tested on 3.3.3
I fixed this issue in https://github.com/NServiceBus/NServiceBus/commit/66984e016986fb0f1013f3ec1339b565badf07f4
But there is still a problem if the user instead calls Bus.SendLocal.
I'll raise another bug for that one
Oops already reported in #806
Just out of curiosity, was this a recent regression or has this never worked as intended with the distributor?
Looking at the code it has never worked as intended in 3.X
SendLocal worked in 2.6 though - https://github.com/NServiceBus/NServiceBus/blob/v2.5/src/unicast/NServiceBus.Unicast/UnicastBus.cs#L490
Need to digg a little more regarding the HandleCurrentMessageLater
On Wed, Jan 2, 2013 at 1:40 PM, Jan Ove Skogheim Olsen < [email protected]> wrote:
Just out of curiosity, was this a recent regression or has this never worked as intended with the distributor?
— Reply to this email directly or view it on GitHubhttps://github.com/NServiceBus/NServiceBus/issues/851#issuecomment-11806702.
http://andreasohlund.net http://twitter.com/andreasohlund
Could you guys please consider making a 3.3.4 release with this and #806? It's biting us in production and I'd really like not to have to do a major upgrade to 4.0.0, considering all the new stuff added there, just to get this fixed.
The message needs to be sent back to the distributor
Hi @janovesk,
I've just created a beta release that addresses both these issues #806 and #851. Would you mind testing it out and report back, once I hear from you I'll organise an official 3.3.4 release.
You can get this beta from nuget or from our build server (the build server includes the zip + msi).
Great, I'll test it now and let you know. Thanks!
Alright, I've tested and can confirm that 3.3.4-beta2 works fine for us. Both SendLocal and HandleCurrentMessageLater put the message on the distributor input queue and send a ready messages on the distributor control queue, as expected.
@janovesk thanks a lot for testing this for us :smile: We are working out a release date, it shouldn't be too far away.