web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

CRM 2015 SQL deadlocks on ProcessSessionBase table

(0) ShareShare
ReportReport
Posted on by 139

Hi All,

One of the Dynamics CRM 2015 apps has some data import workflows that worked previously, before I even got put in charge of this app. Months ago, the business admin, who imports the csv files into the wizard, noticed the data not getting updated properly. I've scratched my head at those for months, so im really hoping to get some help here! 

The csv files can have anywhere from 5k records to 40k. At one point, the 40k record file was being processed at just fine, but now even a few hundred records get hung up. 

Here the process: 

  • The files get imported
  • Each record gets created as a Account staging record into CRM
  • On creation of the staging records, Workflows get kicked off to determine what to do with this data. 

The first SearchAccount plugin activity queries the Account entity with the staging record entity data, outputs the matched account reference, if any, and an action whether to Create, Update, or Deactivate. 

Based on that action from SearchAccount, it then goes into CreateAccount, UpdateAccount, or Deactivate plugin activity. 

It then does some similar logic on the Contacts for the Accounts. 

There are some additional workflows that happen after all this, but the workflows for the Accounts are severely impacted and process very slowly so the others dont get a chance to run. Out of the file with 5k records, maybe 100 go through successfully after an hour then eventually stick in Waiting with a timeout, "Generic SQL error", or suspended. I got to a point in my UAT environment where the success rate was almost perfect, which I would settle with for now since I want to move this whole solution to Datastage/SSIS and the admin as the abiliy to select the failed ones to re run, but this is bugging me like crazy. 

What got me to my success rate in UAT was adding the Sandbox Timeouts registry edits on the BE servers and increasing them like here: http://balarajann.blogspot.com/2015/05/how-to-increase-sandbox-time-out-above.html I also had the DBA change the RCSI propery  like here:https://willwarren.com/2015/10/12/sql-server-read-committed-snapshot/

I made my changes to Prod and nothing happened. When I run the imports and watch the logs on the SQL DB Server, I see SQL deadlocks on the dbo.ProcessSessionBase table. The deadlock reports also have details like the process {hostname}.MSCRMAsyncservice and the user running it SI_FltCRMAsync. Im really leaning towards an issue with this applications database, but my DBA wasnt able to identify anything. I know if I went into depth on the plugin code and logic, I would probably get told to refactor a lot. Due to restraints on my knowledge of Dynamics, other active projects I need to focus on, etc that's something I cant take on right now. It doesnt make sense to me that Prod is the only instance where these issues occur, even if the imports are ran off business hours where users are not on the system. 

The Assembly with the plugin activities in Sandbox mode. 

This is not something happening in UAT, so Im at a complete loss! I cant find anything on the internet about this particular scenario. 

Ive follow the steps to clean out asyncoperationbase table: https://support.microsoft.com/en-us/help/968520/performance-is-slow-if-the-asyncoperationbase-table-becomes-too-large

Ive restarted BE servers, CRM services, and iisresets on the FE servers. There are 2 other apps on the platform and they dont have these issues. 

I appreciate any recommendations or help in advance!!

I have the same question (0)
  • kunihih Profile Picture
    on at

    In order to troubleshoot deadlock issues such as this we would need to take a look at a SQL Server profile trace and a Dynamics CRM platform trace that was taken during a repro of the issue. I would recommend you log a support case with Microsoft to help you analyze these traces. You can obtain a Dynamics CRM platform trace with the steps in the following page.

    support.microsoft.com/.../how-to-enable-tracing-in-microsoft-dynamics-crm

    You can obtain a SQL Profile trace with the relevant information with the following steps:

    1) Start SQL Profiler

    2) Click on File - Templates - New Template

    3) In general tab: select the correct SQL version and a name for the template

    4) Most import is the event selection tab.

    4) Activate these events:

    - Tick all events beneath “Errors and Warnings”

    - Tick all events beneath “TSQL”

    - Tick these events beneath “Stored Procedures”:

    RPC:* (all RPC events)

    SP.Starting

    SP.Completed

    Stmt:Starting

    Stmt:Completed

    - Tick these events beneath “Locks”:

    Deadlock Graph

    Lock:Deadlock

    Lock:Deadlock Chain

    Lock:Escalation

    Lock:Timeout

    Lock:Timeout (timeout >0)

    Now you are ready to save your SQL profiler template.

    You now want to capture a SQL profiler trace using this template during problem reproduction.

    This is what you need to do:

    1. Start SQL Profiler

    2. Connect to the correct SQL Server instance (the instance that contains your <ORG>_MSCRM database)

    3. Click on File and choose “New Trace” in order to create a new trace

    3.1. Choose the template that you created before (see above) – beneath drop-down “use the template”

    3.2. Tick the option to “save the trace to file”

    3.3. Raise the default file size from 5 MB to 100 MB

    4.    Start the trace and stop it immediately by clicking the red square

    5.    Do an IISReset (only if possible – means if you can still reproduce the issue after IISreset – some performance issues are gone after IISreset)

    6.    Prepare your problem reproduction in CRM so that you are only “one click” away from reproducing (in order to keep the trace small)

    7.    Start the SQL Profiler trace (click the green arrow) – you don’t need to save the trace from the first start (4)

    8.     Reproduce the issue now.

    9.    Stop the SQL Profile trace immediately after reproduction - It should not become too large

    10.  Save the trace once again under a new file second file name (different from 3.2) for security reason – then you won’t loose any information

  • damccracken Profile Picture
    139 on at

    Update: I have tried to isolate the issue a little further. I ended up making a simple workflow that had 2 steps, send me and email then make a record inactive. No plugin code activities. This workflow still had the same behavior where a few succeeded then others got stuck in "waiting" with this error:

    Workflow suspended temporarily due to error: Unhandled Exception: Microsoft.Crm.CrmException: Generic SQL error.

      at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

      at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)

    The process sessions in "Waiting"  will eventually get retired and go through successfully, but this same behavior is very annoying and impacting more complex workflows.

  • damccracken Profile Picture
    139 on at

    Thanks for the reply Kunihiko. I dont have access to do all this myself, ill have to work with a DBA to get this SQL profiler set up like this. I have opened a case with Microsoft so hopefully they can quickly identify the issue.

    I did have an update i just posted below. If you could take a look at it  and let me know if you have any additional tips, that would be appreciated!

  • David Jennaway Profile Picture
    14,065 on at

    Sounds like there's something not right in your configuration, though it's hard to tell where. Are your UAT and Production environments running on the same servers (as different databases), or one different deployments on different servers ? If they are on the same servers, then it's most likely to be SQL Settings, as most of the CRM settings (e.g. registry keys) apply to all organisations for those servers.

    For SQL Settings, if you can, I'd try changing the Read Committed Snapshot Isolation; there's no one setting that is best for every environment. I'd also want to know if there are any other processes that access the database (e.g. if someone had configured replication). If you use SQL Profiler (as per an earlier reply), this should help identify if the deadlocks are solely from CRM components (AsyncService, Sandbox Service or w3wp.exe (direct application usage, and synchronous, non-isolated plugins)), or from something else accessing the database

  • damccracken Profile Picture
    139 on at

    Hi David, I appreciate you replying! UAT and Production are on different servers. The Production database server hosts 2 of 3 Dynamics applications, with the 3rd on its own Database server, and I have confirmed only this one particular application is the only one being impacted by this issue. I've had my DBA change the RCSI db property on the database specific for the impacted application.

    willwarren.com/.../ is what I followed fo that.

    I'll have to work with my DBA on the profiling. Im not sure what you mean by "if someone had configured replication" but there are definitely other processes accessing the database. It doesnt matter what time of day these are run, the behavior is always the same.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 36 Super User 2025 Season 2

#2
Shivani Padalia Profile Picture

Shivani Padalia 36

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans