Transaction Deadlocked on Microsoft Identity Manager MA Export

In a Microsoft Identity Manager development environment, I had just defined a series of rules and was keen to export a large number of users to the MIM Service. I was pretty confident that I’d done everything correct however it was clear very quickly that something was wrong. The number of errors when running an export run profile to the MIM Service was increasing quickly. The errors were Transaction Deadlocked errors, however I was only running a single run profile. Just an export on the MIM Service MA.

Message: Transaction (Process ID 60) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Looking into the Event Log on the MIM Sync Server I found all the gory details including the full Transaction Deadlocked error message.

Transaction Deadlocked on lock resources with another process

As mentioned above it wasn’t just one or two errors. But thousands.

Errors on Export.PNG

After some searching and looking at the latest hotfixes for Microsoft Identity Manager I found that the MIM Hotfix Rollup 4.5.412.0 does indeed contain a fix for this issue.

Here is the full Synchronization Service Issue 1 from the 4.5.41.0 MIM Hotfix Rollup.

Issue 1

In MIM build 4.5.286.0, a MIM management agent export may return the following exception:

Fault Reason: The endpoint could not dispatch the request.\r\n\r\nFault Details: <DispatchRequestFailures xmlns="http://schemas.microsoft.com/2006/11/ResourceManagement" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><DispatchRequestAdministratorDetails><FailureMessage>Exception: Other

Stack Trace: Microsoft.ResourceManagement.WebServices.Exceptions.UnwillingToPerformException: Other ---&gt; System.Data.SqlClient.SqlException: Reraised Error 50000, Level 13, State 1, Procedure ReRaiseException, Line 37, Message: Reraised Error 50000, Level 13, State 1, Procedure ReRaiseException, Line 37, Message: Reraised Error 1205, Level 13, State 51, Procedure GenerateRequestOutput, Line 2147, Message: Transaction (Process ID 88) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Microsoft.ResourceManagement.Data.DataAccess.DoRequestCreation(RequestType request, Guid cause, Guid requestMarker, Boolean doEvaluation, Int16 serviceId, Int16 servicePartitionId)

--- End of inner exception stack trace ---

at Microsoft.ResourceManagement.WebServices.RequestDispatcher.CreateRequest(UniqueIdentifier requestor, UniqueIdentifier targetIdentifier, OperationType operation, String businessJustification, List`1 requestParameters, CultureInfo locale, Boolean isChildRequest, Guid cause, Boolean doEvaluation, Nullable`1 serviceId, Nullable`1 servicePartitionId, UniqueId messageIdentifier, UniqueIdentifier requestContextIdentifier, Boolean maintenanceMode)
at Microsoft.ResourceManagement.WebServices.RequestDispatcher.CreateRequest(UniqueIdentifier requestor, UniqueIdentifier targetIdentifier, OperationType operation, String businessJustification, List`1 requestParameters, CultureInfo locale, Boolean isChildRequest, Guid cause, Boolean doEvaluation, Nullable`1 serviceId, Nullable`1 servicePartitionId, UniqueId messageIdentifier)
at Microsoft.ResourceManagement.WebServices.ResourceManagementService.Create(Message request)</FailureMessage><DispatchRequestFailureSource>Other</DispatchRequestFailureSource><AdditionalTextDetails>Request could not be dispatched.</AdditionalTextDetails></DispatchRequestAdministratorDetails><CorrelationId>fc548590-4306-4e1a-bb93-074f51f6757d</CorrelationId></DispatchRequestFailures>

After you install this update, this problem no longer occurs.

Looking at the version I was running, in was in fact one version behind the most current release and the one identified in the hotfix rollup as having the issue.

MIM Versions.PNG

After applying the hotfix to my environment and re-running the export to the MIM Service it was in a much happier state.

Successful Export without Deadlock Errors.PNG

Summary

Don’t panic, check the latest hotfixes and maybe you’ll get lucky. Posting this in case I see this issue again and I can find the details on how to remediate quickly.