Page 1 of 1

This MySqlTransaction has completed; it is no longer usable

Posted: Thu 18 Jul 2019 10:03
by sabbir
Hi,
we've a wcf service through which end user on iPad send orders. For long time, it is working with no error. From few days, we are receiving error via mail. My .net framework version is 4.6, EntityFramework version is 6.1.31219.0 & Devart.Data.MySql.Entity.EF6.dll version is 8.6.714.0.The error is coming from IEnumerable.Any Method. I know Entityframework automatically manage transaction in Save, Update & Delete operation. From Stack Trace, it seems IEnumerable.Any is maintaining transaction internally(calling ObjectContext.ExecuteInTransaction internally).The code is given bellow

Code: Select all

var device = _deviceRep.Get(Globals.CurrentDevice.UUID);
if(Globals.CurrentCompany.DomainName != "" && !device.CompanyDevices.Any(cd => cd.CompanyId == Globals.CurrentCompany.Id && cd.DeviceId == device.Id))
{
  ......			
}

The exception details are bellow

Exception Message:
An error occurred while closing the provider connection. See the inner exception for details.

Inner Exception Message:
This MySqlTransaction has completed; it is no longer usable.

Stack Trace:
at System.Data.Entity.Core.EntityClient.EntityConnection.StoreCloseHelper() at System.Data.Entity.Core.Objects.ObjectContext.ReleaseConnection() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClassb.b__9() at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Entity.Core.Objects.DataClasses.EntityCollection`1.Load(List`1 collection, MergeOption mergeOption) at System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad() at System.Data.Entity.Core.Objects.DataClasses.EntityCollection`1.GetEnumerator() at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at nVision.Office.Core.Modules.Device.WSDevice.VerifyDevice() in c:\nVision Office MVC\Codebase\nVision.WebService\Core\Modules\Company\Device\WSDevice.svc.cs:line 154 at nVision.WebService.Global.VerifyClientAccess(Boolean requireCompanyAuth, Boolean requireDeviceAuth) in c:\nVision Office MVC\Codebase\nVision.WebService\Global.asax.cs:line 325 at nVision.Office.Modules.Order.WSOrder.SaveOrder(Orderhead order) in c:\nVision Office MVC\Codebase\nVision.WebService\Modules\Order\WSOrder.svc.cs:line 527

Please let me know the possible cause for which it is happening. Need your help.

Best Regards
Sabbir

Re: This MySqlTransaction has completed; it is no longer usable

Posted: Mon 22 Jul 2019 14:14
by Shalex
1. Had something changed in your environment before the issue occurred? (MySQL or EF version upgrade, etc)

2. You are working with an outdated version (8.6.714 11-Aug-16). Could you please upgrade to the newest build (8.13.1422 04-July-19)?

3. Try to localize the problem and send us a small test project with the corresponding DDL/DML script for reproducing the error in our environment.

Re: This MySqlTransaction has completed; it is no longer usable

Posted: Tue 23 Jul 2019 07:55
by sabbir
Thanks for you reply
1. I think i increased the value of CommandTimeout from 30 sec to 120 sec of MySqlCommand in three methods, In those methods i didn't open any transactions.
2. We have a plan to update version.
3. It is very difficult to localize the problem because the problem is not happening always.All of a sudden i am facing the issue.If i run the service manually the error never happens.


thanks

Re: This MySqlTransaction has completed; it is no longer usable

Posted: Wed 24 Jul 2019 17:04
by Shalex
We need to reproduce the issue to start our investigation. If you manage to localize the problem, send us a small test project with the corresponding DDL/DML script.

General recommendations: https://stackoverflow.com/a/6359095/135566.