U4-7546 - Cannot delete document type - fanoe starter kit Text Page

Created by Shannon Deminick 16 Dec 2015, 14:02:17 Updated by Mads Rasmussen 25 Jan 2016, 10:10:27

I haven't dug into the details yet but if you install the fanoe starter kit and then try to delete the Text Page doc type, you'll get a server error and the Js will explode, so firstly:

  • The YSOD dialog should be displayed
  • And then we need to fix so this actually works

Here's the full stack trace/result:

)]}',
{"Message":"An error has occurred.","ExceptionMessage":"The DELETE statement conflicted with the REFERENCE constraint \"FK_umbracoAccess_umbracoNode_id\". The conflict occurred in database \"v74\", table \"dbo.umbracoAccess\", column 'nodeId'.\r\nThe statement has been terminated.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":"   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\r\n   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n   at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in c:\\Code\\github\\SamSaffron\\MiniProfiler\\StackExchange.Profiling\\Data\\ProfiledDbCommand.cs:line 279\r\n   at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass2_0.<ExecuteNonQueryWithRetry>b__0() in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\PetaPocoCommandExtensions.cs:line 56\r\n   at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\FaultHandling\\RetryPolicy.cs:line 174\r\n   at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\PetaPocoCommandExtensions.cs:line 50\r\n   at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy retryPolicy) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\PetaPocoCommandExtensions.cs:line 34\r\n   at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\PetaPocoCommandExtensions.cs:line 22\r\n   at Umbraco.Core.Persistence.Database.Execute(String sql, Object[] args) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\PetaPoco.cs:line 606\r\n   at Umbraco.Core.Persistence.Repositories.PetaPocoRepositoryBase`2.PersistDeletedItem(TEntity entity) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\Repositories\\PetaPocoRepositoryBase.cs:line 76\r\n   at Umbraco.Core.Persistence.Repositories.ContentRepository.PersistDeletedItem(IContent entity) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\Repositories\\ContentRepository.cs:line 336\r\n   at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.PersistDeletedItem(IEntity entity) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\Repositories\\RepositoryBase.cs:line 343\r\n   at Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\UnitOfWork\\PetaPocoUnitOfWork.cs:line 115\r\n   at Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Persistence\\UnitOfWork\\PetaPocoUnitOfWork.cs:line 92\r\n   at Umbraco.Core.Services.ContentService.Umbraco.Core.Services.IContentServiceOperations.Delete(IContent content, Int32 userId) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Services\\ContentService.cs:line 1170\r\n   at Umbraco.Core.Services.ContentService.Delete(IContent content, Int32 userId) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Services\\ContentService.cs:line 1277\r\n   at Umbraco.Core.Services.ContentService.DeleteContentOfType(Int32 contentTypeId, Int32 userId) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Services\\ContentService.cs:line 1256\r\n   at Umbraco.Core.Services.ContentTypeService.Delete(IContentType contentType, Int32 userId) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Core\\Services\\ContentTypeService.cs:line 621\r\n   at Umbraco.Web.Editors.ContentTypeController.DeleteById(Int32 id) in X:\\Projects\\Umbraco\\Umbraco_7.4\\src\\Umbraco.Web\\Editors\\ContentTypeController.cs:line 80\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}

Comments

Robert Foster 12 Jan 2016, 15:02:41

I frequently come across this issue or something similar when deleting document types that have been used by content. For example, if I change the document type on a content node, and then try to delete the old document type (making sure no other node is associated with it) then it will blow up like this.

What I suspect is happening is that old versions of the content nodes are still associated with the document type, and hence result in the database conflicts.

Generally in my case the work around is to first delete the custom properties from the document type and then I'm able to delete the document type itself. However I haven't noticed anything to do with the umbracoAccess table, so maybe not quite the same.


Claus Jensen 13 Jan 2016, 10:36:57

I am not able to replicate this issue in the 7.4.0-beta (which is the version affected set on this issue).

  • Running the installer
  • Installing the Fanoe starterkit during install
  • Going to document types deleting the Text Page document type (I tested I can delete everything in there)
  • Ensuring all document types and content created using these document types have been deleted
  • No ysod's or errors has been shown

Tested with both SQL server and SQLCE since the error reported seemed to be referring to a sql constraint.


@rfoster I don't think that is related to this issue. We however already have that bug logged as an issue here so I'll forward you to that one instead :) http://issues.umbraco.org/issue/U4-7698


Claus Jensen 13 Jan 2016, 10:38:07

@Shandem could you update with instructions on how to replicate if you can still make this happen?


Shannon Deminick 13 Jan 2016, 10:43:22

I'll see if i can find instructions to replicate from an empty install, I still have this issue with 7.4 beta, will move this to next sprint though.


Shannon Deminick 13 Jan 2016, 18:19:59

Probably related, but when i just tried to uninstall a package called 'semicolon starter kit', i get a similar YSOD:

The DELETE statement conflicted with the REFERENCE constraint "FK_umbracoAccess_umbracoNode_id1". The conflict occurred in database "v74", table "dbo.umbracoAccess", column 'loginNodeId'.
The statement has been terminated.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_umbracoAccess_umbracoNode_id1". The conflict occurred in database "v74", table "dbo.umbracoAccess", column 'loginNodeId'.
The statement has been terminated.

Source Error: 


Line 54:                 try
Line 55:                 {
Line 56:                     return command.ExecuteNonQuery();
Line 57:                 }
Line 58:                 finally

Source File: X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs    Line: 56 

Stack Trace: 


[SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_umbracoAccess_umbracoNode_id1". The conflict occurred in database "v74", table "dbo.umbracoAccess", column 'loginNodeId'.
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +3279044
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +791
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4927
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +442
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +3114
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +554
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +475
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +386
   StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:279
   Umbraco.Core.Persistence.<>c__DisplayClass2_0.<ExecuteNonQueryWithRetry>b__0() in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:56
   Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction(Func`1 func) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\FaultHandling\RetryPolicy.cs:174
   Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:50
   Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command, RetryPolicy retryPolicy) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:34
   Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteNonQueryWithRetry(IDbCommand command) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:22
   Umbraco.Core.Persistence.Database.Execute(String sql, Object[] args) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\PetaPoco.cs:606
   Umbraco.Core.Persistence.Repositories.PetaPocoRepositoryBase`2.PersistDeletedItem(TEntity entity) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\Repositories\PetaPocoRepositoryBase.cs:76
   Umbraco.Core.Persistence.Repositories.ContentRepository.PersistDeletedItem(IContent entity) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\Repositories\ContentRepository.cs:343
   Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.Remove(TEntity entity, Action`1 persistMethod) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Cache\DefaultRepositoryCachePolicy.cs:72
   Umbraco.Core.Persistence.Repositories.RepositoryBase`2.PersistDeletedItem(IEntity entity) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\Repositories\RepositoryBase.cs:262
   Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\UnitOfWork\PetaPocoUnitOfWork.cs:115
   Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Persistence\UnitOfWork\PetaPocoUnitOfWork.cs:92
   Umbraco.Core.Services.ContentService.Umbraco.Core.Services.IContentServiceOperations.Delete(IContent content, Int32 userId) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Services\ContentService.cs:1170
   Umbraco.Core.Services.ContentService.Delete(IContent content, Int32 userId) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Services\ContentService.cs:1277
   Umbraco.Core.Services.ContentService.DeleteContentOfType(Int32 contentTypeId, Int32 userId) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Services\ContentService.cs:1256
   Umbraco.Core.Services.ContentTypeService.Delete(IContentType contentType, Int32 userId) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Core\Services\ContentTypeService.cs:656
   umbraco.presentation.developer.packages.installedPackage.confirmUnInstall(Object sender, EventArgs e) in X:\Projects\Umbraco\Umbraco_7.4\src\Umbraco.Web\umbraco.presentation\umbraco\developer\Packages\installedPackage.aspx.cs:461
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11757857
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6016

Definitely something to do with Public Access assignments


Shannon Deminick 20 Jan 2016, 17:27:22

Commit: 2d0f198f58071f5113d5c3437f10f2b85220c348

The fix was to remove the public access data before the associated umbraco node data. To test this: Create a doc type, create some content with it, assign public access to one of those nodes, then delete the doc type, it should work.


Shannon Deminick 21 Jan 2016, 10:42:34

@sebastiaan this should be back ported to 7.3.6, i'll update the due in version


Mads Rasmussen 25 Jan 2016, 10:10:20

Added to 7.3.6: https://github.com/umbraco/Umbraco-CMS/commit/2d0f198f58071f5113d5c3437f10f2b85220c348


Priority: Task - Pri 1

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.3.0, 7.4.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5

Due in version: 7.3.6

Sprint: Sprint 7

Story Points:

Cycle: