We are trying to identify a problem that we think is a NHibernate related problem. We have developed an ASP.NET application (NET 2.0) that uses Enterprise Library (2.0) and NHibernate (1.2.0). It’s compiled for any processor and runs in a native x64 environment (2003 STE, IIS 6). It uses a SQL Server (05, x64, clustered with active/passive).
Within unspecified intervals we get the following exceptions and in the numbered order. When we set pooling to false we only get the first exception.
Exception 1
Code:
<InnerException>
<ExceptionType>System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)</Message>
<Source>.Net SqlClient Data Provider</Source>
<HelpLink />
<Property name="Errors">System.Data.SqlClient.SqlErrorCollection</Property>
<Property name="Class">20</Property>
<Property name="LineNumber">0</Property>
<Property name="Number">10060</Property>
<Property name="Procedure"><undefined value></Property>
<Property name="Server" />
<Property name="State">0</Property>
<Property name="ErrorCode">-2146232060</Property>
<Property name="Data">System.Collections.ListDictionaryInternal</Property>
<Property name="TargetSite">System.Data.ProviderBase.DbConnectionInternal GetConnection(System.Data.Common.DbConnection)</Property>
<StackTrace> at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()</StackTrace>
</InnerException>
Exception 2
Code:
<InnerException>
<ExceptionType>System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.</Message>
<Source>System.Data</Source>
<HelpLink />
<Property name="Data">System.Collections.ListDictionaryInternal</Property>
<Property name="TargetSite">System.Data.ProviderBase.DbConnectionInternal GetConnection(System.Data.Common.DbConnection)</Property>
<StackTrace> at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()</StackTrace>
</InnerException>
Connection strings
Nhibernate
Code:
<property name="connection.connection_string"> Server=192.168.197.140;initial catalog=myDatabase; Network=DBMSSOCN; User ID= myUsername; Password="myPassword"; min pool size="4"; max pool size="100";</property>
Enterprise Library
Code:
<connectionStrings><add name="ElConnection" connectionString=" Network=DBMSSOCN; Database=myDatabase; Server=192.168.197.140; UID=myUsername; PWD=myPassword; min pool size=4; max pool size=100;" providerName="System.Data.SqlClient" />
</connectionStrings>
When the first exception occurs, the connection pool that NHibernate uses goes down. Nothing happens with the EL pool. The connection pool is empty until someone tries to access the application and then the pool goes back to normal again. But since the first exception occurs even though we turn off pooling we are not so sure it is pooling problem. The logs for SQL Server and network don’t indicate any problem. We are not sure this is a NHibernate related problem, but since it is only the NHibernate pool that goes down it might be.