Issues with Content Staging

Michael Legacy asked on May 22, 2019 21:16

Hey there, I'm having some issues with data disparity when it comes to content staging. Getting the following error. Has anyone else had this issue and resolved it?

Do I basically need to clear all the data from the tables on the source server and do a full sync again?

SyncServer.ServerError: Exception occurred: [DataConnection.HandleError]: 
Query: INSERT INTO CMS_Document ([DocumentName], [DocumentNamePath], [DocumentModifiedWhen], [DocumentModifiedByUserID], [DocumentForeignKeyValue], [DocumentCreatedByUserID], [DocumentCreatedWhen], [DocumentCheckedOutByUserID], [DocumentCheckedOutWhen], [DocumentCheckedOutVersionHistoryID], [DocumentPublishedVersionHistoryID], [DocumentWorkflowStepID], [DocumentPublishFrom], [DocumentPublishTo], [DocumentUrlPath], [DocumentCulture], [DocumentNodeID], [DocumentPageTitle], [DocumentPageKeyWords], [DocumentPageDescription], [DocumentShowInSiteMap], [DocumentMenuItemHideInNavigation], [DocumentMenuCaption], [DocumentMenuStyle], [DocumentMenuItemImage], [DocumentMenuItemLeftImage], [DocumentMenuItemRightImage], [DocumentPageTemplateID], [DocumentMenuJavascript], [DocumentMenuRedirectUrl], [DocumentUseNamePathForUrlPath], [DocumentStylesheetID], [DocumentContent], [DocumentMenuClass], [DocumentMenuStyleHighlighted], [DocumentMenuClassHighlighted], [DocumentMenuItemImageHighlighted], [DocumentMenuItemLeftImageHighlighted], [DocumentMenuItemRightImageHighlighted], [DocumentMenuItemInactive], [DocumentCustomData], [DocumentExtensions], [DocumentTags], [DocumentTagGroupID], [DocumentWildcardRule], [DocumentWebParts], [DocumentRatingValue], [DocumentRatings], [DocumentPriority], [DocumentType], [DocumentLastPublished], [DocumentUseCustomExtensions], [DocumentGroupWebParts], [DocumentCheckedOutAutomatically], [DocumentTrackConversionName], [DocumentConversionValue], [DocumentSearchExcluded], [DocumentLastVersionNumber], [DocumentIsArchived], [DocumentHash], [DocumentLogVisitActivity], [DocumentGUID], [DocumentWorkflowCycleGUID], [DocumentSitemapSettings], [DocumentIsWaitingForTranslation], [DocumentSKUName], [DocumentSKUDescription], [DocumentSKUShortDescription], [DocumentWorkflowActionStatus], [DocumentMenuRedirectToFirstChild], [DocumentCanBePublished], [DocumentInheritsStylesheet], [DocumentPageBuilderWidgets]) 
VALUES (@DocumentName, @DocumentNamePath, @DocumentModifiedWhen, @DocumentModifiedByUserID, @DocumentForeignKeyValue, @DocumentCreatedByUserID, @DocumentCreatedWhen, @DocumentCheckedOutByUserID, @DocumentCheckedOutWhen, @DocumentCheckedOutVersionHistoryID, @DocumentPublishedVersionHistoryID, @DocumentWorkflowStepID, @DocumentPublishFrom, @DocumentPublishTo, @DocumentUrlPath, @DocumentCulture, @DocumentNodeID, @DocumentPageTitle, @DocumentPageKeyWords, @DocumentPageDescription, @DocumentShowInSiteMap, @DocumentMenuItemHideInNavigation, @DocumentMenuCaption, @DocumentMenuStyle, @DocumentMenuItemImage, @DocumentMenuItemLeftImage, @DocumentMenuItemRightImage, @DocumentPageTemplateID, @DocumentMenuJavascript, @DocumentMenuRedirectUrl, @DocumentUseNamePathForUrlPath, @DocumentStylesheetID, @DocumentContent, @DocumentMenuClass, @DocumentMenuStyleHighlighted, @DocumentMenuClassHighlighted, @DocumentMenuItemImageHighlighted, @DocumentMenuItemLeftImageHighlighted, @DocumentMenuItemRightImageHighlighted, @DocumentMenuItemInactive, @DocumentCustomData, @DocumentExtensions, @DocumentTags, @DocumentTagGroupID, @DocumentWildcardRule, @DocumentWebParts, @DocumentRatingValue, @DocumentRatings, @DocumentPriority, @DocumentType, @DocumentLastPublished, @DocumentUseCustomExtensions, @DocumentGroupWebParts, @DocumentCheckedOutAutomatically, @DocumentTrackConversionName, @DocumentConversionValue, @DocumentSearchExcluded, @DocumentLastVersionNumber, @DocumentIsArchived, @DocumentHash, @DocumentLogVisitActivity, @DocumentGUID, @DocumentWorkflowCycleGUID, @DocumentSitemapSettings, @DocumentIsWaitingForTranslation, @DocumentSKUName, @DocumentSKUDescription, @DocumentSKUShortDescription, @DocumentWorkflowActionStatus, @DocumentMenuRedirectToFirstChild, @DocumentCanBePublished, @DocumentInheritsStylesheet, @DocumentPageBuilderWidgets); 

SELECT SCOPE_IDENTITY() AS [ID] Caused exception: Cannot insert duplicate key row in object 'dbo.View_CMS_Tree_Joined' with unique index 'IX_View_CMS_Tree_Joined_NodeSiteID_DocumentCulture_NodeID'. The duplicate key value is (1, en-US, 208). The statement has been terminated.

Recent Answers


Brenden Kehren answered on May 22, 2019 21:41

You don't need to remove all the records, simply find which one is duplicated and remove it. The better solution is to make sure your content entry is done at the point at which you want it to start. For instance if you have 3 environments:

  • Dev
  • Stage
  • Prod

IF you're working in dev and pushing to stage AND your content editors are working in stage and pushing to prod, you'll run into this error all the time. Same is true if you only have 2 environments and people are editing in your prod environment. If the records in prod aren't synced back to the dev/stage environment, they will never know they exist and get the duplicate key error like you are getting.

If you are not in production yet with the environment you're staging to, yes a simple delete of the content from the tree will help and then do a full sync of the tree. But need to fix the underlying problem because you don't want to continue doing this.

1 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 23, 2019 07:56

Just to add to what Brended wrote, from the error message it looks like that staging is trying to insert a duplicate node with ID=208 -> IX_View_CMS_Tree_Joined_NodeSiteID_DocumentCulture_NodeID'. The duplicate key value is (1, en-US, 208) Where "1" represents the NodeSiteID, "en-us" is the DocumentCulture and "208" is the NodeID. Just like the index is named. I hope it will help to find the duplicate(s) .

0 votesVote for this answer Mark as a Correct answer

Michael Legacy answered on May 23, 2019 21:04

Thanks for your answers. We have too much content that appears out of syncs, so I'm going with the Blank install approach. This is just a dev server, so we can blow it away.

However, I'm trying to export my Local site through the Site Export feature and when it gets to pages, I get the following error:

Any ideas?

ERROR:  Error exporting pages
Message: 
[DataConnection.HandleError]: 

Then a big long SQL query, and the following stack trace:

Caused exception: 
Operand type clash: uniqueidentifier is incompatible with int


Exception type: System.Exception
Stack trace: 
at CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, Exception ex)
at CMS.DataEngine.AbstractDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
at CMS.DataEngine.GeneralConnection.RunQuery(QueryParameters query)
at CMS.DataEngine.GeneralConnection.RunQueryWithRetry(QueryParameters query, Int32 retryCount)
at CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query, Int32& totalRecords)
at CMS.DataEngine.DataQueryBase`1.GetDataFromDBInternal()
at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
at CMS.DataEngine.DataQueryBase`1.GetData()
at CMS.DataEngine.DataQueryBase`1.get_Result()
at CMS.DataEngine.DataQueryBase`1.GetResults(IDataQuery query, Int32& totalRecords)
at CMS.DataEngine.DataQueryBase`1.GetDataFromDB()
at CMS.DocumentEngine.DocumentQueryProperties.GetDataInternal(IDocumentQuery query, Func`1 baseGetDataMethod, Action`1 setTotalRecords)
at CMS.DataEngine.DataQueryBase`1.GetData()
at CMS.DataEngine.DataQueryBase`1.get_Result()
at CMS.DataEngine.MultiObjectQueryBase`3.EnsureTypedResult()
at CMS.DocumentEngine.Compatibility.NodesDataProvider.GetDataSet()
at CMS.DocumentEngine.DocumentExport.GetExportData_Before(Object sender, ExportGetDataEventArgs e)
at CMS.Base.AbstractHandler.CallEventHandler[TArgs](EventHandler`1 h, TArgs e)
at CMS.Base.AbstractHandler.Raise[TArgs](String partName, List`1 list, TArgs e, Boolean important)
at CMS.Base.AdvancedHandler`2.RaiseBefore(TArgs e)
at CMS.Base.AdvancedHandler`2.RaiseBefore(TArgs e)
at CMS.Base.AdvancedHandler`2.StartEvent(TArgs e, Boolean allowEvent)
at CMS.CMSImportExport.ExportProvider.GetExportData(SiteExportSettings settings, WhereCondition where, String objectType, Boolean childData, Boolean selectionOnly, TranslationHelper th)
at CMS.CMSImportExport.ExportProvider.ExportObjects(SiteExportSettings settings, String objectType, Boolean siteObjects, Boolean childData, Boolean selectionOnly, TranslationHelper th, GeneralizedInfo infoObj, ProcessObjectEnum processType)
at CMS.CMSImportExport.ExportProvider.GetExportData(SiteExportSettings settings, String objectType, Boolean siteObjects, Boolean childData, Boolean selectionOnly, TranslationHelper th)
at CMS.DocumentEngine.DocumentExport.ExportDocumentsData(SiteExportSettings settings, TranslationHelper th)
at CMS.DocumentEngine.DocumentExport.ExportObjects_Before(Object sender, ExportEventArgs e)
at CMS.Base.AbstractHandler.CallEventHandler[TArgs](EventHandler`1 h, TArgs e)
at CMS.Base.AbstractHandler.Raise[TArgs](String partName, List`1 list, TArgs e, Boolean important)
at CMS.Base.AdvancedHandler`2.RaiseBefore(TArgs e)
at CMS.Base.AdvancedHandler`2.StartEvent(TArgs e, Boolean allowEvent)
at CMS.CMSImportExport.ExportProvider.ExportObjectType(SiteExportSettings settings, TranslationHelper th, String objectType, Boolean siteObjects)
at CMS.CMSImportExport.ExportProvider.ExportObjectsData(SiteExportSettings settings)

Message: Operand type clash: uniqueidentifier is incompatible with int

Exception type: System.Data.SqlClient.SqlException
Stack trace: 
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
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.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at CMS.DataEngine.AbstractDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)
0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 23, 2019 21:44

Instead of exporting and importing, simply take a backup of the current database and restore that database to your new environment. After you do that, update the settings you need to in order for it to function as your new environment. Typically this is a few settings keys and your site's domain name.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.