K2 upgrade script SourceCode.Data.5.1007.1000.0.PostUpgrade.sql failure

During an upgrade, the execution of the SourceCode.Data.5.1007.1000.0.PostUpgrade.sql script fails with:

ExecuteSqlScript.Execute: Logged Error: Script execute failed: System.Exception: Script execution exception: System.Data.SqlClient.SqlException (0x80131904): Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.

   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 SourceCode.Data.ReliableDbConnection.<>c__DisplayClass44_0`1.<ExecuteCommand>b__0(IDbConnection connection)

   at SourceCode.Data.ReliableDbConnection.<>c__DisplayClass46_0.<ExecuteDelegate>b__1()

   at SourceCode.Data.Logging.IDataLoggingProviderExtensions.<>c__DisplayClass0_0.<ExecuteAction>b__0()

   at SourceCode.Data.Logging.IDataLoggingProviderExtensions.ExecuteAction[TResult](IDataLoggingProvider provider, RetryPolicy retryPolicy, Func`1 func)

   at SourceCode.Data.Logging.IDataLoggingProviderExtensions.<>c__DisplayClass0_0.<ExecuteAction>b__0()

   at SourceCode.Data.Logging.IDataLoggingProviderExtensions.ExecuteAction[TResult](IDataLoggingProvider provider, RetryPolicy retryPolicy, Func`1 func)

   at SourceCode.Data.ReliableDbConnection.ExecuteDelegate(Func`2 action)

   at SourceCode.Data.ReliableDbConnection.ExecuteCommand[T](ReliableDbCommand command, CommandBehavior behavior)

   at SourceCode.Data.Dac.ExecuteNonQuery(CommandType commandType, String commandText, IEnumerable`1 parameters)

   at SourceCode.Install.SQL.DBQuery.<>c__DisplayClass30_1.<ExecuteRetryableTransactionalScript>b__0(IReliableDbTransaction transaction)

This may be due to an invalid ServiceObject in the [SmartBroker].[ServiceObjectXmlBackup] table.  Execute the following the SQL select query to see if any rows are returned:

SELECT *

FROM [SmartBroker].[ServiceObjectXmlBackup]

WHERE [SystemName] IS NULL OR [SystemName] = ''


If a record(s) is returned, make a back up of the current database state or table [SmartBroker].[ServiceObjectXmlBackup], delete this invalid record, relaunch the Setup Manager and perform the Recover step.


If you are unsure if this is the same issue, consider logging a Support case to verify.


Comments

Popular posts from this blog

Blocking Error during K2 5.6 Server migration

Client Credentials flow with K2 Cloud with Odata, Workflow REST or SCIM

Blocking error RegisterServiceInstanceObjects when upgrading to K2 5.6/5.7