TechSavvySam
TechSavvySam

Reputation: 1442

ASP.NET application exception causes IIS process to crash

I have a misbehaving 3rd party ASP.NET application that is causing IIS to crash. I can't understand how application that throws a simple, unhandled primary key exception is a sufficient reason to kill the web server process.

I was under the mistaken impression that putting a site in it's own application pool would somehow insulate other sites on the web server from errant behavior. I understand that maybe an application that had run-away resource consumption might kill the entire process, but I don't understand how one vendor's unhandled application exception can be allowed to negatively affect every other site on the web server.

I did some web searches and saw that this may happen if a site repeatedly has issues (default setting 5 times in 5 minutes) but that's not what's happening here. What's happening here is every time this exception happens, which is about once every 3 or 4 days, the whole IIS process aborts and causes a momentary outage of ALL of my sites on this web server.

I may possibly have some obscure setting misconfigured. For the most part, my IIS sites and application pools are configured with default settings and these servers have been up and running for years before this issue started occurring in September.

Any thoughts would be greatly appreciated.

System Particulars: Windows 2008 R2 IIS 7.5 Patched up to date as of last weekend


Here are parts of the 3 event entries that happen every time this issue occurs:

Application logs an unhandled exception:

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/2/ROOT

Process ID: 4680

Exception: System.Data.SqlClient.SqlException

Message: Violation of PRIMARY KEY constraint 'PK_st_GlobalSettings'. Cannot insert duplicate key in object 'dbo.st_GlobalSettings'. The duplicate key value is (Options, thread_indexerrunning).
The statement has been terminated.

StackTrace:    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Microsoft.ApplicationBlocks.Data.SqlHelperInternal.ExecuteReader(SqlConnection , SqlTransaction , CommandType , String , SqlParameter[] , #XZc )
(rest of stack trace hidden to protect the identity of the application vendor)

IIS logs that there was an unhandled exception:

Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Data.SqlClient.SqlException
Stack:
at Microsoft.ApplicationBlocks.Data.SqlHelperInternal.ExecuteReader(System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlTransaction, System.Data.CommandType, System.String, System.Data.SqlClient.SqlParameter[], #XZc)
(rest of stack trace hidden to protect the identity of the application vendor)

Then IIS crashes:

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x5315a05a
Exception code: 0xe0434352
Fault offset: 0x000000000000940d
Faulting process id: 0x1248
Faulting application start time: 0x01d02b4003b1de26
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 0f2bc4ae-97b4-11e4-ad94-001c23b85f7b

Upvotes: 2

Views: 7232

Answers (3)

HoganNZ
HoganNZ

Reputation: 61

Seems the expected behaviour for unhandled exceptions occuring outside of the request context is to terminate the worker process. So if your third party app is doing some async work for example, and throws an unhandled exception, this will meet the criteria. See https://support.microsoft.com/en-us/kb/911816 for more

Upvotes: 3

Travis
Travis

Reputation: 21

I have many server 2012 (IIS 8) that I administer and ALL of them are having this problem starting within 48 hours of installing Microsoft updates this month. I checked my application logs over two years and this error had never existed before this month and the only delta in the environment was January's patches!

Upvotes: 2

pointlesspolitics
pointlesspolitics

Reputation: 2480

It is not IIS error. It seems it is a bad request or something else.

The clue is in :"StackTrace: at System.Data.SqlClient.SqlConnection.OnError"

Upvotes: -1

Related Questions