There is already an open DataReader associated with this Command which must be closed first
Hi, After update from 2.1.3 to 2.3 we see a lot of error in log file which connected to not closed Data Reader?
Any idea how to fix it?
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at TeaCommerce.Api.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco, IEnumerable`1 columns)
at TeaCommerce.Api.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco)
at TeaCommerce.Api.Persistence.Repositories.StoreRepository.Save(Store store)
at TeaCommerce.Api.Models.Store.Save()
at TeaCommerce.Api.Models.Store.GetNextOrderNumber(Boolean onlyFinalizedOrders)
at TeaCommerce.Api.Models.Order.Save()
at TeaCommerce.Api.Web.TeaCommerceHelper.GetCurrentOrder(Int64 storeId, Boolean autoCreate)
Example 2
2014-06-12 09:28:55,963 [10] ERROR System.String - [Thread 32] There is already an open DataReader associated with this Command which must be closed first.
System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
Hmm sounds weird as the persistence hasent changed in those versions. Could you try and restart the iis site? Does it happen all the time or just in edge cases?
There is already an open DataReader associated with this Command which must be closed first
Hi, After update from 2.1.3 to 2.3 we see a lot of error in log file which connected to not closed Data Reader?
Any idea how to fix it?
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at TeaCommerce.Api.Persistence.Database.Execute(Sql Sql)
at TeaCommerce.Api.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco, Object primaryKeyValue, IEnumerable`1 columns)
at TeaCommerce.Api.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco, IEnumerable`1 columns)
at TeaCommerce.Api.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco)
at TeaCommerce.Api.Persistence.Repositories.StoreRepository.Save(Store store)
at TeaCommerce.Api.Models.Store.Save()
at TeaCommerce.Api.Models.Store.GetNextOrderNumber(Boolean onlyFinalizedOrders)
at TeaCommerce.Api.Models.Order.Save()
at TeaCommerce.Api.Web.TeaCommerceHelper.GetCurrentOrder(Int64 storeId, Boolean autoCreate)
Example 2
2014-06-12 09:28:55,963 [10] ERROR System.String - [Thread 32] There is already an open DataReader associated with this Command which must be closed first.
System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at TeaCommerce.Api.Persistence.Database.<Query>d__c`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TeaCommerce.Api.Persistence.Repositories.OrderRepository.GetInternal(Int64 storeId, String andQuery)
at TeaCommerce.Api.Persistence.Repositories.OrderRepository.Get(Int64 storeId, Guid orderId)
at TeaCommerce.Api.Models.Order.Save()
Hmm sounds weird as the persistence hasent changed in those versions. Could you try and restart the iis site? Does it happen all the time or just in edge cases?
What DB do you use?
It is happen very often. On acceptance and produciton servers. Reset of iis didn't help us. We even rollback changes from production because of it.
We use MS SQL 2012.
Think i have it fixed. Could you email us at info (at) teacommerce.net and we can send you a nightly to test. Thanks
Hi, looks like issue was fixed in build you send to me. There no any such errors in our log file. When it can be released? Will it be build 2.3.2?
Yes it will be build 2.3.2. Dont have an exact date for release yet :)
I can confirm the 2.3.2 resolves the issue with the database connection not being terminated when an error occurs.
I assume this should be applied to any TeaCommerce installs? Cheers, Laurence
Yes that would be a good idea. So update all to 2.3.2
is working on a reply...