24

I have a site which holds an exclusive lock on some resources. I used the .NET Application_Start and Application_End events to acquire and release the lock on these resources at the appropriate time. For this to work properly, there can only ever be one instance of my application running at any given time.

To get this to happen, I've set the Disable Overlapped Recycle property on the Application pool to True. This property is supposed to ensure that the old worker process shuts down completely before a new one starts up whenever the app pool is recycled. This works fine whenever the app pool is recycled manually through IIS, automatically as the result of the idle-timeout being reached or automatically according to any specific time/time interval rules.

However, when the web.config for the site is updated, this rule isn't getting applied - A new worker process starts up before the old one finishes shutting down. This causes bad things to happen. I have the Disable Recycling for Configuration Changes property set to False as I do want the app pool to get recycled when the web.config is updated - this happens frequently during development.

Is this something which is expected, or is it a bug in IIS? IS my only option to set up so that changing the web.config doesn't recycle the app pool? I'd rather not do this, since I'm pretty sure it will cause many headaches with people changing the configuration and then forgetting to recycle the app pool.

Update:

To be more clear, when the new worker process start event is called before the old worker process has finished shutting down, then the old worker process end event never gets called - It doesn't happen out of sequence, it never happens at all.

  • How long after the web.config is updated before the new worker process is started? – Greg Askew Mar 7 '13 at 15:47
  • The new worker process starts as soon as I try to access the site after a recycle - So less than a second if I'm quick. If left, the old worker process 'shutdown' event takes places 20-30 seconds after the recycle. – John Mar 7 '13 at 15:58
  • I have the same issue. There is overlap – Andrew Rimmer May 1 '14 at 12:43
  • 10
    Editing the web.config file causes the appDomain to reload. The appDomain is seperate from the AppPool. You should not see a new W3WP process id just from changing the web.config. See here treeloop.com/blog/iis-application-domain-and-pool-recycling – kheld Jan 15 '15 at 22:18
  • 1
    @kheld is absolutely right (perhaps add this as answer) this is not an appool overlap, it is an appDomain overlap. I don't believe you can stop this, but you can disable app domain recycling on change. – Sam Cogan May 3 '15 at 23:21
1

From this MSDN Post: https://blogs.msdn.microsoft.com/tess/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles/

So as part of your code deploy process, it looks like your pool will recycle when you deploy any one of these changes:

Immediate Recycle

  • Web.config changes
  • Machine.config changes
  • Global.asax changes
  • Bin directory changes
  • App_Code changes

(borrowed from: https://stackoverflow.com/questions/302110/what-causes-an-application-pool-in-iis-to-recycle )

protected by Community Jun 14 '18 at 21:30

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.