When deleting records in Microsoft Dynamics CRM 4.0, you may notice that they don’t disappear from the database right away. This is due to the fact that when a record is ‘deleted’ in CRM 4.0, it is actually only marked for deletion later by setting the record’s DeletionStateCode value to 2. These marked records are later cleaned up by an internal CRM process known as the Deletion Service (which is really just another process running under the Asynchronous Processing Service). By default, this service is set to run once a day.

So what do you do if after 24 hours the records have still not been removed from the database? In cases where you are dealing with a large database, particularly one where the AsyncOperationBase table has grown very large, you may be dealing with timeouts from the database server. If this is the case, the timeout can be extended by modifying a couple of registry values (note that you modify the registry at your own risk, and you should always make backups first).

Begin by locating the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM, and add a new DWORD value named OLEDBTimeout, setting its value to 86400. Then add a second DWORD value named ExtendedTimeout, and set its value to 1000000.

At this point you should be able to force the deletion service to run again. This can be done by running the following command against the MSCRM_CONFIG database of your CRM deployment:

The deletion service will take some time to run. You can check the current status of the service and whether it failed or succeeded using the following query:

The ‘State’ field will indicate whether or not the service is currently running (a 1 means that it is), and the ‘LastResultCode’ will indicate whether or not it was successful (a 0 indicates success).

Once the deletion service has completed successfully, you should revert the registry values that were modified above to be within the normal parameters for CRM (between 30 and 300 for both).

Like this post? Share it!