
Dear Experts,
Recently I have faced a strange issue in Dynamics CRM 2015 On-Premise instance.
Functionality:
We have a custom workflow that schedule to run daily, this will update an Entity1 record status.
On Entity1 Status update, we have plug-in to update Entity2.
On Entity2 Status update, we have plug-in to update Entity3.
On Entity3 Status update, we have plug-in to update Entity4 (Master Entity).
Basically, 3 level of Plug-ins. All these plug-ins registered as Synchronous.
In this scenario, we have only 1 Master record and all the 55 records are trying to update this one record.
Issue:
Custom workflow ran on 55 records at a time, first 15 records were completed as successful and other records went to waiting stage. Server Event viewer logged different types of errors and some of the errors summary as below:
Initial Error:
ServerName; CrmAsyncService.exe (1908); ACF75705; execution time:00:01:25.4526639/ServerName; Microsoft.Crm.Sandbox.HostService.exe (2764); D1FF8028; execution time:00:01:25.4526639; Plug-in Name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd55c642b9a72843:Plug-inName/ServerName; Microsoft.Crm.Sandbox.WorkerProcess.exe (4504); 539A2153; execution time:00:01:04.9520100/-
Error-1:
Entity-1
30
Update
Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.Crm.Extensibility.InternalOperationPlugin
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
Error-2:
plugintype
30
RetrieveMultiple
Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.Crm.Extensibility.InternalOperationPlugin
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
Note: I have googled the issue and some blogs suggested to declare the "Server" object at Execute function level instead of Class level. I have verified, all the Plug-ins steps are registered at Execute function level only.
Kindly let me know what is causing the error?
*This post is locked for comments
I have the same question (0)This is likely caused by deadlocks in SQL Server.
Here's a related thread: https://social.microsoft.com/Forums/en-US/f858bd11-237f-41fa-8fca-83c78fee32a3/bug-crm-2011-executing-workflow-on-multiple-records-gives-sometimes-status-failed-or-waiting?forum=crmdevelopment
If you're using QueryExpression in your plug-ins, check into setting NoLock to true, if this makes sense for what your plug-ins need to do.
Since you're running on-premises CRM, you can use SQL tools to check for deadlocks. Check with your database admin for assistance.
From your description of your plug-ins, I believe a redesign might be necessary. Can you post one of the plug-ins so we can look into this further?