Can't Add Page & Navigation Blown Up

Topics: Troubleshooting
Jul 12, 2013 at 2:13 AM
Edited Jul 12, 2013 at 2:17 AM
Really have no idea what happened here... I upgraded a 1.4 site to 1.6.1 with what seemed to be no issue. Started adding some new content types to display as projections on an existing page. Added content to them without issue, display is fine too. Then went to make a new page and got a 404 at /admin/contents/edit/[the ID]

Message says "Your Page has been created", but no message/prompt to create a widget layer.
Content zone just says Not Found or 404 Not found depending on if I press save or publish.

Try to find the page(s) in Content (normally would be top of the list) nothing... do a search and again nothing.

Glanced at the logs (Orchard logs, nothing in the event viewer)and then went to see the Navigation module and bam! This is what I see :
An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back
could not execute query [ SELECT this_.Id as Id66_3_, this_.Number as Number66_3_, this_.Published as Published66_3_, this_.Latest as Latest66_3_, this_.Data as Data66_3_, this_.ContentItemRecord_id as ContentI6_66_3_, contentite1_.Id as Id65_0_, contentite1_.Data as Data65_0_, contentite1_.ContentType_id as ContentT3_65_0_, menupartre2_.Id as Id81_1_, menupartre2_.MenuText as MenuText81_1_, menupartre2_.MenuPosition as MenuPosi3_81_1_, menupartre2_.MenuId as MenuId81_1_, contenttyp6_.Id as Id67_2_, contenttyp6_.Name as Name67_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Navigation_MenuPartRecord menupartre2_ on contentite1_.Id=menupartre2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE menupartre2_.MenuId = @p0 and this_.Published = @p1 ] Name:cp0 - Value:11 Name:cp1 - Value:True [SQL: SELECT this_.Id as Id66_3_, this_.Number as Number66_3_, this_.Published as Published66_3_, this_.Latest as Latest66_3_, this_.Data as Data66_3_, this_.ContentItemRecord_id as ContentI6_66_3_, contentite1_.Id as Id65_0_, contentite1_.Data as Data65_0_, contentite1_.ContentType_id as ContentT3_65_0_, menupartre2_.Id as Id81_1_, menupartre2_.MenuText as MenuText81_1_, menupartre2_.MenuPosition as MenuPosi3_81_1_, menupartre2_.MenuId as MenuId81_1_, contenttyp6_.Id as Id67_2_, contenttyp6_.Name as Name67_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Navigation_MenuPartRecord menupartre2_ on contentite1_.Id=menupartre2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE menupartre2_.MenuId = @p0 and this_.Published = @p1]
NHibernate.Exceptions.GenericADOException: could not execute query [ SELECT this_.Id as Id66_3_, this_.Number as Number66_3_, this_.Published as Published66_3_, this_.Latest as Latest66_3_, this_.Data as Data66_3_, this_.ContentItemRecord_id as ContentI6_66_3_, contentite1_.Id as Id65_0_, contentite1_.Data as Data65_0_, contentite1_.ContentType_id as ContentT3_65_0_, menupartre2_.Id as Id81_1_, menupartre2_.MenuText as MenuText81_1_, menupartre2_.MenuPosition as MenuPosi3_81_1_, menupartre2_.MenuId as MenuId81_1_, contenttyp6_.Id as Id67_2_, contenttyp6_.Name as Name67_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Navigation_MenuPartRecord menupartre2_ on contentite1_.Id=menupartre2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE menupartre2_.MenuId = @p0 and this_.Published = @p1 ] Name:cp0 - Value:11 Name:cp1 - Value:True [SQL: SELECT this_.Id as Id66_3_, this_.Number as Number66_3_, this_.Published as Published66_3_, this_.Latest as Latest66_3_, this_.Data as Data66_3_, this_.ContentItemRecord_id as ContentI6_66_3_, contentite1_.Id as Id65_0_, contentite1_.Data as Data65_0_, contentite1_.ContentType_id as ContentT3_65_0_, menupartre2_.Id as Id81_1_, menupartre2_.MenuText as MenuText81_1_, menupartre2_.MenuPosition as MenuPosi3_81_1_, menupartre2_.MenuId as MenuId81_1_, contenttyp6_.Id as Id67_2_, contenttyp6_.Name as Name67_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id inner join Navigation_MenuPartRecord menupartre2_ on contentite1_.Id=menupartre2_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp6_ on contentite1_.ContentType_id=contenttyp6_.Id WHERE menupartre2_.MenuId = @p0 and this_.Published = @p1] ---> System.Data.SqlClient.SqlException: Invalid column name 'MenuId'. Invalid column name 'MenuId'. 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) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) 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.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) --- End of inner exception stack trace --- at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at NHibernate.Impl.CriteriaImpl.List(IList results) at NHibernate.Impl.CriteriaImpl.List[T]() at Orchard.ContentManagement.DefaultContentQuery.ContentQuery`1.Orchard.ContentManagement.IContentQuery<T>.List() in c:\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 191 at Orchard.Core.Navigation.Services.MainMenuService.GetMenuParts(Int32 menuId) in c:\Orchard\src\Orchard.Web\Core\Navigation\Services\MainMenuService.cs:line 23 at Orchard.Core.Navigation.Controllers.AdminController.Index(NavigationManagementViewModel model, Nullable`1 menuId) in c:\Orchard\src\Orchard.Web\Core\Navigation\Controllers\AdminController.cs:line 70 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
Unfortunately because I don't know when or how this happened my options are to rollback everything to the current live 1.4.2 site and try to retrace my steps, or just rebuild it from scratch on 1.7.0 when it launches (not a huge site and most of the data seems accessible and uncorrupted).

Just thought I'd share this even though 1.7 should be coming out any day.
Coordinator
Jul 12, 2013 at 2:30 AM
It says in there "Invalid column name 'MenuId'", and that should be on Navigation_MenuPartRecord. Looks like a migration didn't work properly. Check what columns you have in this table. It would be interesting to see what version you had in Orchard_Framework_DataMigrationRecord for Orchard.Navigation before the migration, as well as the table structure for Navigation_MenuPartRecord. Then compare with what you have after the migration. The column is added in UpgradeFrom2.
Jul 12, 2013 at 2:47 AM
Navigation_MenuItemPartRecord: Id and Url
Navigation_MenuPartRecord: Id MenuText MenuPosition MenuRecord id
Migration Record said version 3 so I changed it to 2 to trigger an update and get the same error
Coordinator
Jul 12, 2013 at 3:01 AM
Maybe the application doesn't have enough permissions on the DB to make schema changes. What's weird is that the migration should throw. Can you attach a debugger and break into the migration step to verify what's going on?
Jul 12, 2013 at 6:17 PM
OK so the update did throw an error... not sure how I missed it last night:
MigrationInterpreter.cs:line 347
   at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.Visit(CreateTableCommand command) in c:\Orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 94
   at Orchard.Core.Navigation.Migrations.UpdateFrom1() in c:\Orchard\src\Orchard.Web\Core\Navigation\Migrations.cs:line 100
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Orchard.Data.Migration.DataMigrationManager.Update(String feature) in c:\Orchard\src\Orchard\Data\Migration\DataMigrationManager.cs:line 105
2013-07-12 10:13:25,757 [20] Orchard.Data.Migration.DataMigrationManager - An unexpected error orccured while applying migration on Navigation from version 1
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: There is already an object named 'Navigation_AdminMenuPartRecord' in the database.
   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.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.RunPendingStatements() in c:\Orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 347
   at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.Visit(CreateTableCommand command) in c:\Orchard\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 94
   at Orchard.Core.Navigation.Migrations.UpdateFrom1() in c:\Orchard\src\Orchard.Web\Core\Navigation\Migrations.cs:line 100
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object
Jul 12, 2013 at 6:29 PM
OK so here's how I resolved this...
I deleted all Navigation_ tables, deleted the Navigation migrations entry in Orchard_Framework_DataMigrationRecord (tried setting it to 1 and 0 with no results prior), recycled the app pool then updated the Navigation module. Success!

Kinda strange eh?

Thanks for your speedy replies Bertrand! Nothing says love like being a part of the Orchard community ;)
Coordinator
Jul 13, 2013 at 9:05 AM
Glad you could fix it.