locked
Deadlocks and Timeouts occurring in multithreaded batch delete application RRS feed

  • Question

  • Hi,

    We have a requirement to delete records(nearly 0.4 million) quickly from CRM 2011.I have written an application that deletes records using multithreading.While executing batch delete using mutithreading, deadlocks and timeouts are occurring.

    It deleted fine without multithreading but it is taking very long time.Hence tried to use mutithreading to speedup the deletion.

    Can any one help me on this issue?

    Thanks in advance

    Swathi 



    Friday, March 28, 2014 9:21 AM

All replies

  • Two things you could try are:

    • Setting the database to Snapshot Isolation mode. This may help, but may not
    • If you have plugins on the delete message (or Retrieve or RetrieveMultiple) on the entities being deleted, then disable them if possible

    Other than that, you don't have any control over the locking.

    The other option is to upgrade to CRM 2013. Now that it has no ExtensionBase tables, it is much less prone to deadlocks - see http://mscrmuk.blogspot.co.uk/2013/12/crm-2013-no-more-extensionbase-tables.html


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, March 28, 2014 11:20 AM
    Moderator
  • I can think of 3 possibilities, but it depends on your requirement:

    1. Use ExecuteMultipleRequest
    2. Create and execute a bulk delete job
    3. Create a special entity that takes your criteria or list of ids and put a plugin on it that actually does the deletes.

    Unfortunately they all have their down sides, you can only run 2 executemultiple requests at once in CRM on-line, and there's a limit to the number of requests in each ExecuteMultipleRequest (although you can split them up). If it's on-premise then I believe the limitations are less and you have some control.

    Option 2 will run as a background task, so you can't wait for it.

    Option 3 is a lot of work to write and can be difficult to handle errors with, although if the plugin is synchronous you can at least wait for it. Additionally you have to be careful how many things you delete per entity create/plugin call..


    Friday, March 28, 2014 12:51 PM