NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

NServiceBus fails to shutdown (4.3.0)

Open ianbattersby opened this issue 12 years ago • 9 comments

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! ;-)

ianbattersby avatar Dec 17 '13 10:12 ianbattersby

Anyone?

ianbattersby avatar Dec 21 '13 08:12 ianbattersby

Are those messages blowing up when deserializing?

andreasohlund avatar Dec 21 '13 10:12 andreasohlund

if those messages can't be processed (including sagas) for whatever reason

What do you mean?

johnsimons avatar Dec 23 '13 03:12 johnsimons

I think the scenario goes a bit like this;

  1. We have some services running with sagas that use timeouts
  2. Some sagas are 'active' in that they have timeouts pending
  3. 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.
  4. 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.

tapmantwo avatar Dec 23 '13 09:12 tapmantwo

I get NSB to hang indefinitely during shutdown on stopResetEvent.WaitOne(); when MSMQ runs out of allocated storage

STR

  1. Change ComputerManagement->Services and Applications->Message Queuing->Properties->Limit message storage to something very small
  2. Start a self hosted endpoint that sends messages (eventually Bus.Send will throw MessageQueueException Insufficient resources to perform operation)
  3. Call Bus.Shutdown

Following above STR also continues to perform timeout polling.

EDIT: looks like onCriticalErrorAction calls IStartableBus.Shutdown() and it hangs

chrisbednarski avatar Jan 17 '14 01:01 chrisbednarski

Are u selfhosting?

johnsimons avatar Jan 17 '14 02:01 johnsimons

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 avatar Jan 17 '14 02:01 johnsimons

@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)

chrisbednarski avatar Jan 17 '14 05:01 chrisbednarski

Closing as can't repro

andreasohlund avatar Sep 12 '14 19:09 andreasohlund