I'm just putting this out there in case it is useful to anyone.
I accidentally created an infinite busy-loop:
Code:
while (true)
{
runNHibernateQueryThatReturnsZeroRecords();
}
In turn, every few (hundred) iterations I'd get an error:
Code:
NHibernate.ADOException: could not execute query
[ SELECT blah query blah ]
Positional parameters: 0 Running
[SQL: blah query blah] ---> System.InvalidOperationException: Invalid operation. The connection is closed.
at System.Data.OracleClient.OracleConnection.GetOpenInternalConnection()
at System.Data.OracleClient.OracleConnection.get_ErrorHandle()
at System.Data.OracleClient.OracleDataReader.FillColumnInfo()
at System.Data.OracleClient.OracleDataReader..ctor(OracleCommand command, OciStatementHandle statementHandle, String
statementText, CommandBehavior commandBehavior)
at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters query
Parameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
--- End of inner exception stack trace ---
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
at NHibernate.Impl.CriteriaImpl.List()
at My.Code.LoopForever()
Since I didn't realize this was looping so fast, I didn't realize that there were many queries that worked (and didn't generate a log message) for every one that didn't work. Couple that with the fact that the first time I got this problem was IMMEDIATELY after I had reinstalled the oracle client drivers on this computer, I spent a long time trying to debug what the heck was wrong with the oracle install instead of realizing I had a bug in my code.
I suspect this has nothing intrinsically to do with NHibernate in this case, I think my infinite loop interfered with another thread that used the same session object (after the loop exited, in theory).
So anyway, if you get this "Invalid operation. The connection is closed." error, I just want to remind you to check your code for excessive or overlapping queries.