Friday, March 29, 2013

Resolution: Errors After Installing Update Rollup for Dynamics CRM 2011

After installing an update rollup for Dynamics CRM 2011 ( I was installing UR12, but others have gotten the same error with outher URs), I started getting this error.


Log Name: Application Source: ASP.NET 4.0.30319.0 Date: 3/28/2013 8:40:04 AM Event ID: 1309 Task Category: Web Event Level: Warning Keywords: Classic User: N/A Computer: crm_server.domain.local Description: Event code: 3005 Event message: An unhandled exception has occurred. Event time: 3/28/2013 8:40:04 AM Event time (UTC): 3/28/2013 1:40:04 PM Event ID: 857c1ec3a88c43799878637451e1b3a7 Event sequence: 36389 Event occurrence: 23 Event detail code: 0 Application information: Application domain: /LM/W3SVC/1/ROOT-1-140088322863478416 Trust level: Full Application Virtual Path: / Application Path: C:\Program Files\Microsoft Dynamics CRM\CRMWeb\ Machine name: CRM_SERVER Process information: Process ID: 3508 Process name: w3wp.exe Account name: DOMAIN\service_account Exception information: Exception type: CrmException Exception message: Attribute objecttypecode on Entity PrincipalObjectAccessReadSnapshot is of type picklist but has Child Attributes Count 0 at
Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal() at Microsoft.Crm.Application.Platform.ServiceCommands.RetrieveMultipleCommand.Execute() at Microsoft.Crm.ApplicationQuery.RetrieveMultipleCommand.RetrieveData() at Microsoft.Crm.ApplicationQuery.ExecuteQuery() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.GetData(QueryBuilder queryBuilder) at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadQueryData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareGridData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareData() at Microsoft.Crm.Application.Controls.GridUIProvider.Render(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.RenderData(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.RenderInnerHtml(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.Render(HtmlTextWriter output) at ASP.claimsopssupporttest_tools_emailtemplateeditor_emailtemplateeditor_aspx.__RendercrmForm(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at Microsoft.Crm.Application.Forms.EndUserForm.Render(HtmlTextWriter output) at ASP.claimsopssupporttest_tools_emailtemplateeditor_emailtemplateeditor_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Request information: Request URL:     Request path: /CRMOrg/tools/emailtemplateeditor/emailtemplateeditor.aspx      Thread information: Thread ID: 24 Thread account name:
Stack trace: at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal() at Microsoft.Crm.Application.Platform.ServiceCommands.RetrieveMultipleCommand.Execute() at Microsoft.Crm.ApplicationQuery.RetrieveMultipleCommand.RetrieveData() at Microsoft.Crm.ApplicationQuery.ExecuteQuery() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.GetData(QueryBuilder queryBuilder) at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadQueryData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareGridData() at Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareData() at Microsoft.Crm.Application.Controls.GridUIProvider.Render(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.RenderData(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.RenderInnerHtml(HtmlTextWriter output) at Microsoft.Crm.Application.Components.UI.Grid.DataGrid.Render(HtmlTextWriter output) at ASP.claimsopssupporttest_tools_emailtemplateeditor_emailtemplateeditor_aspx.__RendercrmForm(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at Microsoft.Crm.Application.Forms.EndUserForm.Render(HtmlTextWriter output) at ASP.claimsopssupporttest_tools_emailtemplateeditor_emailtemplateeditor_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I poked around a little and noticed that the update rollup wasn't applied to one of my organization database. We have two organization databases and one was at UR12 and the other was still at UR11. In deployment manager, I tried to manually update the database and it failed. That led me to this error that was in C:\Users\username\AppData\Roaming\Microsoft\MSCRM\Logs\crm50dmsnapin.log.

09:05:35| Error| Installer Complete: OrganizationDatabaseHotFixer - Error encountered 09:05:36| Error| Exception occured during Microsoft.Crm.Tools.Admin.OrganizationDatabaseHotFixer: Action Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction failed. InnerException: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.DependencyBase' with unique index 'ndx_UniqueDependencyNodes'. The duplicate key value is (guid). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command) at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace) at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace) at Microsoft.Crm.BusinessEntities.SimpleBulkInserterWithType.Flush(ISqlExecutionContext context) at Microsoft.Crm.ObjectModel.DependencyHelperBase.BulkInsertDependencies(BusinessEntityCollection dependencies, ISqlExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.CreateComponentDependencies(Dictionary`2 recordsByComponentType, ExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.ProcessRecords(ExecutionContext context) at Microsoft.Crm.BusinessEntities.ExecutionContext.ProcessDependencies(FlushCacheOption option, CreateNewCollectorOption createOption) at Microsoft.Crm.BusinessEntities.ExecutionContext.OnEndRequest() at Microsoft.Crm.Setup.MetadataPatchService.ProcessMetadataDiffFile(String targetRevision) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId) at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall) at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall) at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase) at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters) at Microsoft.Crm.Setup.Common.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo) InnerException: System.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.DependencyBase' with unique index 'ndx_UniqueDependencyNodes'. The duplicate key value is (guid). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command) at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace) at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace) at Microsoft.Crm.BusinessEntities.SimpleBulkInserterWithType.Flush(ISqlExecutionContext context) at Microsoft.Crm.ObjectModel.DependencyHelperBase.BulkInsertDependencies(BusinessEntityCollection dependencies, ISqlExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.CreateComponentDependencies(Dictionary`2 recordsByComponentType, ExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.ProcessRecords(ExecutionContext context) at Microsoft.Crm.BusinessEntities.ExecutionContext.ProcessDependencies(FlushCacheOption option, CreateNewCollectorOption createOption) at Microsoft.Crm.BusinessEntities.ExecutionContext.OnEndRequest() at Microsoft.Crm.Setup.MetadataPatchService.ProcessMetadataDiffFile(String targetRevision) ClientConnectionId:be6bf5ae-acf5-4fe2-83a8-53e2gfe8a2a3 09:05:36| Info| Setting organization state. New state = Failed 09:05:36| Error| Update Organization with Id=(guid) failed with Exception: System.Exception: Action Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction failed. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.DependencyBase' with unique index 'ndx_UniqueDependencyNodes'. The duplicate key value is (guid). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command) at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace) at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace) at Microsoft.Crm.BusinessEntities.SimpleBulkInserterWithType.Flush(ISqlExecutionContext context) at Microsoft.Crm.ObjectModel.DependencyHelperBase.BulkInsertDependencies(BusinessEntityCollection dependencies, ISqlExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.CreateComponentDependencies(Dictionary`2 recordsByComponentType, ExecutionContext context) at Microsoft.Crm.Dependency.ComponentCollector.ProcessRecords(ExecutionContext context) at Microsoft.Crm.BusinessEntities.ExecutionContext.ProcessDependencies(FlushCacheOption option, CreateNewCollectorOption createOption) at Microsoft.Crm.BusinessEntities.ExecutionContext.OnEndRequest() at Microsoft.Crm.Setup.MetadataPatchService.ProcessMetadataDiffFile(String targetRevision) --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.Crm.Setup.Database.DllMethodAction.Execute(Guid organizationId) at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseInfo releaseInfo, Boolean isInstall) at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall) at Microsoft.Crm.Setup.Database.DatabaseInstaller.InstallUpdate(String configurationFilePath, Boolean upgradeDatabase) at Microsoft.Crm.Setup.Common.Update.DBUpdateDatabaseInstaller.ApplyDBUpdates(Guid orgId) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdatesInternal(Guid orgId, String orgUniqueName, String releaseFilePath, Boolean ignoreErrors) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.ApplyDBUpdates(Guid orgId, String orgUniqueName, OrganizationOperationType operationType) at Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction.Do(IDictionary parameters) at Microsoft.Crm.Setup.Common.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo) --- End of inner exception stack trace --- at Microsoft.Crm.Setup.Common.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo) at Microsoft.Crm.Setup.Common.Installer.Install(IDictionary stateSaver) at Microsoft.Crm.Tools.Admin.OrganizationOperation.Install(IDictionary stateSaver) at Microsoft.Crm.Tools.Admin.OrganizationOperation.Execute() at Microsoft.Crm.Tools.Admin.OrganizationDatabaseHotFixer.Execute() at Microsoft.Crm.Tools.Admin.ApplyDatabaseHotFixInstaller.ApplyDatabaseHotFix(IApplyDatabaseHotFixInfo applyDatabaseHotFixInfo)

The problem was with one of the ndx_UniqueDependencyNodes indexs. To fix that problem we followed a suggestion we found on http://social.microsoft.com/Forums/en-US/crm/thread/cf12f112-f9b7-4504-925e-7d837e32a808?prof=required that said to "open the index 'ndx_UniqueDependencyNodes' for 'dbo.DependencyBase' and select 'Skip repeating values' option on 'Parameters' tab. This option is next after 'Rebuild index'."

After that I was able up manually update the organization database from the deployment manager successfully. Unfortunately, we were still getting our original error. We ended up rebuilding that same index on the other organization database that originally was updated successfully while installing the update rollup, and the errors went away on the entire environment.