Skip to content

SQL Exception when restoring content with relations #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BenWhite27 opened this issue Apr 17, 2025 · 0 comments
Open

SQL Exception when restoring content with relations #261

BenWhite27 opened this issue Apr 17, 2025 · 0 comments

Comments

@BenWhite27
Copy link

I'm trying to restore from an Umbraco Cloud environment into my Development environment and get the following error.

"An error occurred when saving the relateDocumentOnCopy relation."

Reproduction

Bug summary

Unable to transfer content from Live to Development environments due to a SQL error related to a relationship between documents.

Specifics

This was whilst doing a partial restore with specified content including items below. The target environment is empty, so this is a fresh restore.

Steps to reproduce

Unsure, but given the error I imagine having an environment with documents that are related to each other and trying to restore them produces this error.

Expected result

The transfer should succeed, and relations should be copied successfully.

Actual result

Exception as follows.

Umbraco.Deploy.Core.Exceptions.EnvironmentException: An error occured when saving the relateDocumentOnCopy relation between parent node ID 2035 (umb://document/b50dadc2d6ed45b19f40b3dc439d89d1) and child node ID 2015 (umb://document/a42ee2f0b94f4f8e93763ed4a7c42bbf).
 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_umbracoRelation_umbracoNode1". The conflict occurred in database "akg1tuweqgu", table "dbo.umbracoNode", column 'id'.
The statement has been terminated.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar()
   at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
   at NPoco.Database.ExecuteScalarHelper(DbCommand cmd)
   at NPoco.Database.InsertAsyncImp[T](PocoData pocoData, String tableName, String primaryKeyName, Boolean autoIncrement, T poco, Boolean sync)
   at NPoco.Database.Insert[T](String tableName, String primaryKeyName, Boolean autoIncrement, T poco)
   at NPoco.Database.Insert[T](T poco)
   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.RelationRepository.PersistNewItem(IRelation entity)
   at Umbraco.Cms.Core.Cache.NoCacheRepositoryCachePolicy`2.Create(TEntity entity, Action`1 persistNew)
   at Umbraco.Cms.Core.Services.RelationService.Save(IRelation relation)
   at Umbraco.Deploy.Infrastructure.Core.ArtifactRelator.ProcessRelations(IEnumerable`1 artifacts, IEnumerable`1 relations, CancellationToken token)
ClientConnectionId:82728dc0-d64e-4b9b-bd4a-f90530746666
Error Number:547,State:0,Class:16
ClientConnectionId before routing:787eab2c-3304-4bd0-8ec9-e92881390520
Routing Destination:ce6be563ef3a.tr8899.uksouth1-a.worker.database.windows.net,11063
   --- End of inner exception stack trace ---
   at Umbraco.Deploy.Infrastructure.Core.ArtifactRelator.ProcessRelations(IEnumerable`1 artifacts, IEnumerable`1 relations, CancellationToken token)
   at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.ProcessPackageAsync(Guid sessionId, Package package, CancellationToken cancellationToken)
   at Umbraco.Deploy.Infrastructure.Work.WorkItems.DeployRestoreWorkItemBase.ProcessPackage(Package package, Nullable`1 batchIndex, Nullable`1 numberOfBatches)
   at Umbraco.Deploy.Infrastructure.Work.WorkItems.TargetPartialRestoreWorkItem.Proceed()
   at Umbraco.Deploy.Infrastructure.Work.WorkItems.TargetPartialRestoreWorkItem.ExecuteAsyncSub(IWorkContext context, List`1 resume, CancellationToken token)
   at Umbraco.Deploy.Infrastructure.Work.WorkItems.TargetPartialRestoreWorkItem.ExecuteAsyncSub(IWorkContext context, List`1 resume, CancellationToken token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant