J
Jeff Shepler
This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.
The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:
[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +636
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
What handle????
Sometimes, I get a SemephoreFullException instead:
[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063
System.Data.ProviderBase.DbConnectionPool.PutNewObject(DbConnectionInternal
obj) +54
System.Data.ProviderBase.DbConnectionPool.DeactivateObject(DbConnectionInternal
obj) +228
System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal
obj, Object owningObject) +265
System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbConnection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:
[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +734982
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSni() +638049
System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.ExecuteFlush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:
[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +636
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?
This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it's own application pool on the
production box for now while I'm testing.
The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).
I don't know what to do. I don't know how to troubleshoot this. Days
of googling and searching forums has not helped me.
Please help!
only one I read and there are a lot of smart people that "live" here.
Please don't berate me if you think this should have been posted in
another newsgroup.
The web application I'm currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:
[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +636
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
What handle????
Sometimes, I get a SemephoreFullException instead:
[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063
System.Data.ProviderBase.DbConnectionPool.PutNewObject(DbConnectionInternal
obj) +54
System.Data.ProviderBase.DbConnectionPool.DeactivateObject(DbConnectionInternal
obj) +228
System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal
obj, Object owningObject) +265
System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbConnection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:
[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +734982
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSni() +638049
System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.ExecuteFlush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:
[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject) +636
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?
This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it's own application pool on the
production box for now while I'm testing.
The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).
I don't know what to do. I don't know how to troubleshoot this. Days
of googling and searching forums has not helped me.
Please help!