These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: "Invalid operation. The connection is closed."
PostPosted: Thu Oct 25, 2007 11:08 am 
Newbie

Joined: Thu Oct 25, 2007 9:37 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.