Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

WAS event 5002: application pool "is being automatically disabled due to a series of failures" (Rapid-Fail Protection and 503)

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Event 5002 from the source Microsoft-Windows-WAS reads "Application pool '%1' is being automatically disabled due to a series of failures in the process(es) serving that application pool." IIS has switched the pool off because its worker process kept failing. The pool is the symptom. The cause is the crashes before it, and Microsoft's own remedy is to correct the problem in the application that ran in the worker process and then restart the application pool.

What the event means

Rapid-Fail Protection is a setting of the application pool's failure element. Microsoft's reference says that when it is true the WWW service removes from service all applications in the pool when the number of worker process crashes reaches rapidFailProtectionMaxCrashes within the number of minutes set by rapidFailProtectionInterval. The defaults are true, 5 crashes, and 00:05:00 (five minutes). So by default, five crashes in five minutes disable the pool.

Microsoft's setting reference also explains what visitors see. loadBalancerCapabilities has the default value HttpLevel, which Microsoft describes as meaning a 503 error code has been returned when, for example, an application pool is in rapid-fail protection. A load balancer that is not HTTP-aware therefore still sees a healthy server, because the 503 tells it the computer is healthy.

The crash events are on Microsoft's list of application pool availability events. Event 5009 says a process serving the pool "terminated unexpectedly" and gives the process id and exit code. Event 5010 says a process "failed to respond to a ping". Event 5011 says a process "suffered a fatal communication error with the Windows Process Activation Service" and that the data field contains the error number.

Likely causes

Cause What you see How to confirm
Unhandled exception in application code Repeated 5009 or 5011, then 5002 Application log event 1000 for w3wp.exe; a .NET Runtime event 1026 for managed code
Access violation in native code Same pattern Event 1000 with exception code 0xC0000005
Infinite recursion Same pattern Event 1000 with exception code 0xC00000fd
Worker process stops answering WAS 5010 pings, then 5011 Events 5010 and 5011 in the System log
Several applications share one pool One faulty application takes all of them down More than one application listed for the pool
Worker process takes too long to start Event 5012 in the System log, then repeated failures Our own reading: Microsoft's availability page lists event 5012 ("exceeded time limits during start up") separately from the failure settings; read that event's text for the process and the time limit

The exception codes above come from Microsoft's page on process crashes, which also says to look for .NET Runtime events with ID 1026 when the code is 0xe0434352, the unhandled CLR exception code.

Prove the cause before changing anything

All steps read only. Run them in this order.

1. Read the pool's state. Microsoft's AppCmd page shows state:Started in this listing. Our own reading: a disabled pool shows a different state value.

%systemroot%\system32\inetsrv\APPCMD list apppools

2. Read the System log. In Event Viewer, expand Windows Logs and select System. Filter for the source Windows Process Activation Service. Find the 5002 event and note its time, then look at the interval set by rapidFailProtectionInterval before it (five minutes by default) for 5009, 5010 and 5011. Write down the application pool name, the process ids and the timestamps. Microsoft's crash page also says to note the time zone of the computer.

3. Read the Application log. Look for events with the source Application Error, type Error and ID 1000 at the same times. Microsoft says to note the faulting application, which for IIS is the worker process w3wp.exe, the faulting module and the exception code.

4. If the code is 0xe0434352, look for .NET Runtime events with ID 1026 at the same times. The description holds the exception and its call stack.

5. List the applications in the pool. Microsoft says that if the pool holds more than one application, one of them may be the culprit, and recommends giving each application its own pool so that a crash is limited to one application. Microsoft's AppCmd page shows list apps printing each application with applicationPool: and the pool name at the end of its line.

%systemroot%\system32\inetsrv\APPCMD list apps

Count the lines that end with the name of the disabled pool. More than one line means the pool is shared.

Microsoft's crash page also describes collecting dumps with Windows Error Reporting, ProcDump or the Debug Diagnostic Tool when the logs are not enough. Those tools change the server (a registry key, a debugger rule or an installed tool), so decide that with whoever owns the application. Microsoft's crash page gives the steps for each tool.

Fix

The 5002 event page gives two actions in order: correct the problem in the application that was running in the worker process (it may have to be debugged and retested), then restart the application pool. The first is application work: deploy the corrected code or configuration. Our own advice: until it is corrected, starting the pool only restarts the same crash cycle.

Two further notes on settings. Microsoft's reference shows that the failure interval and maximum failures can be edited in the pool's Advanced Settings. Our own advice: do not raise them or switch Rapid-Fail Protection off to make the 503 go away, because the worker process is still crashing and the visible symptom would simply move. For a sharper search of the failing layer, see IIS 502 and 503 Errors: Find the Failing Request Layer. If the crash is "access denied" in the application's own logs, see IIS web app gets "access denied" on a folder or share: grant the application pool identity, not Everyone.

Start the pool after the application is corrected

First save the current state:

%systemroot%\system32\inetsrv\APPCMD list apppools > apppools-before.txt

Disruptive step: the next command starts the stopped application pool, so IIS begins serving requests for every application in it again. If the cause of the crashes is still present, the pool crashes again and Rapid-Fail Protection disables it once more after the configured number of failures.

Start the pool. Microsoft's page gives the form appcmd start apppool /apppool.name:string; the same action is in IIS Manager under Application Pools, with the pool selected and Start chosen in the Actions pane.

%systemroot%\system32\inetsrv\APPCMD start apppool /apppool.name:AppPool-Orders

Disruptive step, only if you back out: the command below stops the application pool, so all applications routed to it return 503 Service Unavailable until it is started again, as Microsoft's page states.

To undo it: stop the pool again, which is the opposite action on the same Microsoft page.

%systemroot%\system32\inetsrv\APPCMD stop apppool /apppool.name:AppPool-Orders

Then list the pools and compare with apppools-before.txt.

Example (illustrative): on web01, the site app.example.com returns 503. list apppools shows the pool AppPool-Orders in a state other than Started. The System log shows 5009 five times between 09:10 and 09:13, then one 5002 at 09:13. The Application log shows five matching 1000 events for w3wp.exe with exception code 0xe0434352, and .NET Runtime 1026 events carrying a call stack from the application's start-up code. The developers correct and redeploy the application, and the administrator then saves the pool list and starts the pool.

Confirm the fix

  1. list apppools shows the pool started.
  2. Requests to the site return normal responses instead of 503.
  3. No new 5009, 5010, 5011 or 5002 events appear in the System log over a period longer than the failure interval of five minutes. Our own advice: watch for at least twice that.

What to watch afterwards

  • Our own advice: alert on event 5009 and 5011, not only on 5002. They are the events Microsoft's list shows for individual process failures, so they come before the pool is disabled.
  • Give business-critical applications their own application pool.
  • Keep Application log events 1000 and 1026 long enough to be read after a crash.

Risks and limits

  • These commands have not been run or lab-tested.
  • Microsoft's event pages are written for IIS 7.0 and 7.5; the settings reference states that the failure element was not modified in IIS 8.0, 8.5 or 10.0.
  • Starting a pool whose application is still faulty only repeats the crash cycle and the 503.
  • Collecting crash dumps writes large files; Microsoft advises a drive other than the system drive with enough space.

Sources