Skip to content
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

Umbraco Forms: Duplicate key row in object 'dbo.umbracoRelation' with unique index 'IX_umbracoRelation_parentChildType' #15491

Closed
ewilkinson-marathon opened this issue Dec 20, 2023 · 2 comments
Labels

Comments

@ewilkinson-marathon
Copy link

ewilkinson-marathon commented Dec 20, 2023

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.6

Bug summary

Umbraco Forms form added to a node (in my case added via an "Insert Form" macro within an RTE), it adds a row to the dbo.umbracoRelation table on publish. However, when you try to publish a 2nd time, it is throwing this error:
image. The only way to publish is to manually delete the row matching the given key from the error message.

I thought this would potentially be fixed by today's patch, the "GetRelations" caching fix - however, after just updating, this issue persists.

Note: the same goes for unpublishing/deleting a node that contains an existing form - the same error will display and prevent the action from completing.

Specifics

Server error: Contact administrator, see log for full details.
Cannot insert duplicate key row in object 'dbo.umbracoRelation' with unique index 'IX_umbracoRelation_parentChildType'. The duplicate key value is (3094, 3378, 6). The statement has been terminated.

Umbraco Forms: 12.2.1 (noticed also yesterday at 12.2.0)
Umbraco: 12.3.6 (noticed also yesterday at 12.3.5)

Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.umbracoRelation' with unique index 'IX_umbracoRelation_parentChildType'. The duplicate key value is (2579, 3404, 6). The statement has been terminated. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, 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.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at Microsoft.Data.SqlClient.SqlBulkCopy.RunParser(BulkCopySimpleResultSet bulkCopyHandler)
at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinuedOnSuccess(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinued(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource1 source)
at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsync(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet internalResults, CancellationToken cts, TaskCompletionSource1 source)
at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestAsync(CancellationToken cts, TaskCompletionSource1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalAsync(CancellationToken ctoken) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServerAsync(Int32 columnCount, CancellationToken ctoken) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table, DataRowState rowState) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table) at NPoco.SqlServer.SqlBulkCopyHelper.BulkInsert[T](IDatabase db, IEnumerable1 list, SqlBulkCopyOptions sqlBulkCopyOptions, InsertBulkOptions insertBulkOptions)
at NPoco.SqlServer.SqlBulkCopyHelper.BulkInsert[T](IDatabase db, IEnumerable1 list, InsertBulkOptions insertBulkOptions) at NPoco.DatabaseTypes.SqlServerDatabaseType.InsertBulk[T](IDatabase db, IEnumerable1 pocos, InsertBulkOptions options)
at NPoco.Database.InsertBulk[T](IEnumerable1 pocos, InsertBulkOptions options) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.RelationRepository.SaveBulk(IEnumerable1 relations)
at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentRepositoryBase3.PersistRelations(TEntity entity) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity) at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy2.Update(TEntity entity, Action1 persistUpdated) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase2.Save(TEntity entity)
at Umbraco.Cms.Core.Services.ContentService.<>c__DisplayClass66_0.g__SaveDocument|2(IContent c)
at Umbraco.Cms.Core.Services.ContentService.CommitDocumentChangesInternal(ICoreScope scope, IContent content, EventMessages eventMessages, IReadOnlyCollection1 allLangs, IDictionary2 notificationState, Int32 userId, Boolean branchOne, Boolean branchRoot)
at Umbraco.Cms.Core.Services.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId)
at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PublishInternal(ContentItemSave contentItem, String defaultCulture, String cultureForInvariantErrors, Boolean& wasCancelled, String[]& successfulCultures)
at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSaveInternal[TVariant](ContentItemSave contentItem, Func3 saveMethod, Func2 mapToDisplay)
ClientConnectionId:c5f5ed48-9c18-4b63-861c-3bf0bddd48db
Error Number:2601,State:1,Class:14
ClientConnectionId before routing:53414966-9d07-47f4-a3bc-ae0c4194fdae
Routing Destination:b33f1f523de2.tr31953.eastus1-a.worker.database.windows.net,11057`

Steps to reproduce

Create an umbraco form
Add the form to a page (potentially via an RTE "Insert Form" macro)
Publish the page. (should be successful the first time)
Publish the page again. (should fail here, given the dbo.umbracoRelation table key already exists)

Expected result / actual result

Page should publish/unpublish/delete successfully. Expected that the dbo.umbracoRelations row would be cleared (or incremented, or checked somehow) as to no longer conflict and cause a duplicate unique index error.

Copy link

Hi there @ewilkinson-marathon!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@andr317c
Copy link
Contributor

This issue seems to be a duplicate of #15476. I will go ahead and close this issue. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants