Question

Photo of Mitchell Oller

0

InitializationError after update to 8.0

Hi friends,


So this morning I started the update to 8.0 from 7.5. It looked like everything worked. When I restarted Rock I got the ugly "Server Error in "/" Application" page. I've looked into the application and exception logs and I can't make heads or tales of it. Luckily I have a snapshot I can restore to, so all is not lost. I'm just wondering if there's anything I can do if this happens when I try to update again (or IF I should try to update again.

Here's the Application Log from right after the update

11/7/2018 12:51:53 PM,Application Starting...

11/7/2018 12:52:05 PM,Migrating Database...

11/7/2018 12:52:37 PM,Application Ended: InitializationError


And the ugly system exception log:

11/7/2018 12:52:27 PM,System.Exception,"Error occurred during application startup"," at RockWeb.Global.Application_Start(Object sender, EventArgs e)"
11/7/2018 12:52:27 PM,System.Data.SqlClient.SqlException,"Cannot insert the value NULL into column 'CategoryId', table 'Rock.dbo.AttributeCategory'; column does not allow nulls. INSERT fails.
The statement has been terminated."," 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, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at RockWeb.Global.MigrateDatabase(RockContext rockContext)
at RockWeb.Global.Application_Start(Object sender, EventArgs e)"


  • Photo of Nick Airdo

    1

    It seems like there are two possibilities of something failing during the update (data migration).  If you're comfortable running the SQL Command under your Rock Admin > Power Tools page, try these two queries.  First try this one:

    DECLARE @GroupTypeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.GroupType' )
    DECLARE @AttributeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.Attribute' )   
    SELECT TOP 1 * FROM [Category] WHERE [Name] = 'Check-in' AND [EntityTypeId] = @AttributeEntityTypeId AND [EntityTypeQualifierColumn] = 'EntityTypeId' AND [EntityTypeQualifierValue] = CAST( @GroupTypeEntityTypeId AS varchar)
    

    And see if that returns a single record.  If it does, try this query:

    SELECT * FROM [Category] WHERE [Guid] = '171E45E4-74EC-4962-9AEA-56D899217AFB'

    Let us know if either of those did NOT return a result.

    • Nick Airdo

      For future observers of this issue... Running that first query on his system returned nothing. That is a problem. Because this required "Check-in" category on the Group Type attribute had unfortunately been previously deleted from Mitchell's system, it is causing the upgrade to abort. He received a script to restore the correct record with the correct guid to his system, and he'll eventually retry the update. We'll all cross fingers that there are no other missing items from his system.

  • Photo of Brian Kalwat

    0

    Hey Nick! I came across this same issue - do we still have the script to re-add this category? Does a category with the Guid listed above just need to exist, or is it more complex than that?

    Thanks in advance!

  • Photo of Nick Airdo

    0

    Here was the SQL we had Mitchell run via the  Rock SQL Command tool -- but if you run this there, you'll need to change the "Selection Query" switch to No.


    DECLARE @GroupTypeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.GroupType' )
    DECLARE @AttributeEntityTypeId int = ( SELECT TOP 1 [Id] FROM [EntityType] WHERE [Name] = 'Rock.Model.Attribute' )  
    INSERT INTO [dbo].[Category] ([IsSystem], [ParentCategoryId], [EntityTypeId], [EntityTypeQualifierColumn], [EntityTypeQualifierValue], [Name], [IconCssClass], [Guid], [Order]) 
    VALUES (1, NULL, @AttributeEntityTypeId, N'EntityTypeId', @GroupTypeEntityTypeId, N'Check-in', NULL, N'c8e0fd8d-3032-4acd-9db9-ff70b11d6bcc', 1)