NServiceBus fails to shutdown (4.3.0)
NB: Unfortunately we haven't been able to produce a reproduction yet for this but thought it was worth flagging.
We have noticed that when unprocessed messages are left in the queue (MSMQ in our case) and a new version of our implementation is deployed, if those messages can't be processed (including sagas) for whatever reason, NServiceBus will not shutdown.
In interactive mode, when pressing CTRL-C, NSB states "initiating shutdown" but then (in our case) continued to perform timeout polling regardless. Pressing CTRL-C from this point on-wards had no effect whatsoever. No other errors/messages were logged.
To resolve the issue we cleared the appropriate queues and then NSB behaved as expected. Obviously this wouldn't have been an option on production! ;-)
Anyone?
Are those messages blowing up when deserializing?
if those messages can't be processed (including sagas) for whatever reason
What do you mean?
I think the scenario goes a bit like this;
- We have some services running with sagas that use timeouts
- Some sagas are 'active' in that they have timeouts pending
- There is some error in the handler that means the message cannot be processed. I think in our scenario is it because some other external data has been cleared by our deployment process.
- Our deployment script tries to stop the saga service from running, but it wont stop - it only goes into a STOP_PENDING state. We've tried /uninstall as an option too. In a stand alone host instance, CTRL+C does not shut the saga down either.
If we clear the queues, it all seems to be ok again.
The issue here is that we need to be able to shut down the saga service even if there are messages waiting/failing to be processed.
I get NSB to hang indefinitely during shutdown on stopResetEvent.WaitOne(); when MSMQ runs out of allocated storage
STR
- Change ComputerManagement->Services and Applications->Message Queuing->Properties->Limit message storage to something very small
- Start a self hosted endpoint that sends messages (eventually Bus.Send will throw
MessageQueueExceptionInsufficient resources to perform operation) - Call Bus.Shutdown
Following above STR also continues to perform timeout polling.
EDIT: looks like onCriticalErrorAction calls IStartableBus.Shutdown() and it hangs
Are u selfhosting?
I see how that could cause a dead lock in code. But that is a different issue from this.
BTW, I think this issue is fixed
@johnsimons You're right. Can't reproduce the same hang on develop branch following my STR above. I've found a different condition in develop branch that causes a hang (will log a separate issue)
Closing as can't repro