The connection was not closed.

The connection was not closed.

Postby wgkwvl » Fri 23 Dec 2011 10:53

Hi,

we see following exception appear on occasion in our log files, in the production environment.

Any idea what we can do about this ? It looks to me that the connection returned from the pool cannot be opened, because it is already open ?

Because the error is not reproducable yet, I would consider logging all 'connection' actions, but since the connection does not have a trackable 'id' - property, i dont see how increasing my logging, will help me to find out where this invalid connection comes from, and how to prevent it.

Any tips ?

We are using a client server application with wcf and entity framework,
devart version : 6.30.202.
The error seems to happen in the validation, where a new repository is created which in turn creates a new ef-context object.



Type : System.Data.EntityException, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The underlying provider failed on Open.
Source : System.Data.Entity
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void OpenStoreConnectionIf(Boolean, System.Data.Common.DbConnection, System.Data.Common.DbConnection, System.String, System.String, Boolean ByRef)
Stack Trace : at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Afda.BL.Afda_PatientenServerSideValidator.DoValidate(Object objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validators.AndCompositeValidator.DoValidate(Object objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validators.GenericValidatorWrapper`1.DoValidate(T objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validator`1.Validate(T target, ValidationResults validationResults)
at Afda.BL.Afda_PatientenBL.Validate(Afda_Patienten item, String afdeling_cd)
at Afda.BL.Afda_PatientenBL.Save(Afda_Patienten item, String afdelingCode, BeforeSaveQuestionList responses, Boolean launchPhase2, Afda_Patienten& copybeforesave)


Inner Exception
---------------
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The connection was not closed.
Source : Devart.Data.Oracle
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void Open(Devart.Common.DbConnectionBase)
Stack Trace : at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at Devart.Common.DbConnectionBase.Open()
at Devart.Data.Oracle.OracleConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
wgkwvl
 
Posts: 39
Joined: Tue 20 Jul 2010 15:13

Postby Shalex » Tue 27 Dec 2011 16:53

Please try the following:
1. Make sure that the same connection object is not used in several threads in your code.
2. Upgrade to the latest (6.60.258) version of dotConnect for Oracle.
3. Are you using pooling? If yes ("Pooling=true;"), try "Validate Connection=true;" additionally.
4. Try turning off pooling ("Pooling=false;").

If this doesn't help, please send us a small test project with the corresponding DDL/DML script to reproduce the issue in our environment.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Postby wgkwvl » Mon 16 Jan 2012 10:33

Hi,
1.our saving an object runs in a single thread, ( on WCF)
since EF is responsible for getting its connection , i am not sure how i can
make sure that this connection is not used in another thread ?
2. upgrading to 6.60.258 is not an immediate option, tho it will happen eventually.
3. we added the validate connection = true, (see below)
4. we fear a to great performance impact, so we havent tried this .

we implemented option 3 , and now get this error :

Data : System.Collections.ListDictionaryInternal
TargetSite : System.Data.Common.DbDataReader ExecuteStoreCommands(System.Data.EntityClient.EntityCommand, System.Data.CommandBehavior)
Stack Trace : at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Afda.BL.Afda_PatientenServerSideValidator.DoValidate(Object objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validators.AndCompositeValidator.DoValidate(Object objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validators.GenericValidatorWrapper`1.DoValidate(T objectToValidate, Object currentTarget, String key, ValidationResults validationResults)
at Microsoft.Practices.EnterpriseLibrary.Validation.Validator`1.Validate(T target, ValidationResults validationResults)
at Afda.BL.Afda_PatientenBL.Validate(Afda_Patienten item, String afdeling_cd)
at Afda.BL.Afda_PatientenBL.Save(Afda_Patienten item, String afdelingCode, BeforeSaveQuestionList responses, Boolean launchPhase2, Afda_Patienten& copybeforesave)

Additional Info:

Inner Exception
---------------
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Connection must be opened.
Source : Devart.Data
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior, Boolean)
Stack Trace : at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.Entity.e.a(CommandBehavior A_0)
at Devart.Common.Entity.ak.b(CommandBehavior A_0)
at Devart.Data.Oracle.Entity.e.b(CommandBehavior A_0)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
wgkwvl
 
Posts: 39
Joined: Tue 20 Jul 2010 15:13

Postby Shalex » Wed 18 Jan 2012 17:07

For testing purpose, please try using Oci pooling instead of the dotConnect for Oracle pooling. Just set "Oci Session Pooling=true;" in your connection string.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Postby wgkwvl » Wed 18 Jan 2012 17:20

is OCI session pooling available in direct mode ?
wgkwvl
 
Posts: 39
Joined: Tue 20 Jul 2010 15:13

Postby Shalex » Fri 20 Jan 2012 16:35

OCI session pooling is not available in Direct Mode.
Please try upgrading to the latest (6.60.283) version of dotConnect for Oracle. If this doesn't help, send us a small test project with the corresponding DDL/DML script to reproduce the issue in our environment.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Postby wgkwvl » Mon 23 Jan 2012 07:50

An upgrade will at it soonest only happen in februari,
i will keep you posted.

we have not been able to reproduce the error in our own development environment, so sending a test project will not be possible atm.

The error only occurs in production ( multiple users ? )
wgkwvl
 
Posts: 39
Joined: Tue 20 Jul 2010 15:13


Return to dotConnect for Oracle