Sometimes even the best of the best could be puzzled by the mysterious innerworkings of Dynamics 365/CDS SDK. Tanguy “The XRM Toolbox” Touzard was not having a good day…
For one of my projects, I’m using ReassignObjectsOwnerRequest SDK message to move records from one team to another team. When this request should last more than an amount of time (let say, more than 10 minutes but I did not figure yet what is the exact number), the request never ends on my program.
If I kill the program, then try to reassign records by hand (using Reassign records button in user form), it’s super fast (two seconds or so) and I can then delete the team (which means the reassign process had completed, even if it seems not having ended, from the SDK perspective).
Shan “Jeep Jedi” McArthur, Principal PM at Microsoft, explains:
CDS/CRM 9 is now hosted in Windows Azure and we have Azure firewalls between you and our web servers (as well as between our internal services too). Azure will drop long running connections that exceed 4 minutes. The client application will see this as a dropped connection, but on the server, things continue chugging along until the work completes or errors out. Solution imports are notorious for being long running and that is why we have an async pattern for them and have moved our larger solutions to using async instead of sync. I think this explains the issue you are noticing. The work completes quickly when you do it from the UI because the heavy lifting was done by the request that your original tool sent in and there is little or no work remaining.
Tîpp Jäår takeaway (or take out when in America)
- Avoid long running synchronous operations if you can
- Evaluate the scope of your operation (e.g.
ReassignObjectsOwnerRequest could be massive) and do it “by hand” (e.g. reassign by entity)
- Detect dropped (idle) and timed out connections in your client code
- For non-critical operations, keep your fingers crossed and hope it’ll complete just fine (like it did for Tanguy)
Have a tip about how to deal with long running processes? Email it to email@example.com.