Octopus Upgrade error 2020.6 version from 2020.2.13 version

Hi,

We are upgrading our Octopus instance from 2020.2.13 version to the latest release 2020.6. During the upgrade, we have noticed that it is giving the below error and the upgrade is not happening. We have started noticing this error from version 2020.4.0 itself. It complains about one of the tables, dbo.Script0239ScopedUserRole, cannot be dropped but that the table does not exist as shown in the attached screenshot.

ERROR: SQLException has occured in statement #0 of this TSQL script: ‘Script0253 - Drop no longer needed migration backup tables.sql’; Line: 4; Procedure: ; Error Number: 3701; Excerpt: ‘DROP TABLE [dbo].[Script0239ScopedUserRole]’; Message: Cannot drop the table ‘dbo.Script0239ScopedUserRole’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239Team’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239User’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239UserRole’, because it does not exist or you do not have permission.
2021-03-19 13:05:01.6087 7172 1 WARN Error occured when executing scripts, transaction will be rolled back
2021-03-19 13:05:01.7186 7172 1 ERROR Upgrade failed due to an unexpected exception:
Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot drop the table ‘dbo.Script0239ScopedUserRole’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239Team’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239User’, because it does not exist or you do not have permission.
Cannot drop the table ‘dbo.Script0239UserRole’, because it does not exist or you do not have permission.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.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.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() at DbUp.Support.ScriptExecutor.ExecuteAndLogOutput(IDbCommand command) at Octopus.Core.Initialization.DatabaseUpgrader.OctopusUpgradeScriptExecutor.<>c__DisplayClass7_0.<ExecuteTransactSqlUpgradeScript>b__0(Func1 commandFactory)
at DbUp.Engine.Transactions.SingleTransactionStrategy.Execute(Action1 action) at DbUp.Engine.Transactions.DatabaseConnectionManager.ExecuteCommandsWithManagedConnection(Action1 action)
at Octopus.Core.Initialization.DatabaseUpgrader.OctopusUpgradeScriptExecutor.ExecuteTransactSqlUpgradeScript(IConnectionManager connectionManager, IJournal journal, IUpgradeLog log, SqlScript script, IDictionary2 variables) in C:\BuildAgent\work\b5c671f6c6f2b660\source\Octopus.Core\Initialization\DatabaseUpgrader.cs:line 411 at Octopus.Core.Initialization.DatabaseUpgrader.OctopusUpgradeScriptExecutor.Execute(SqlScript script, IDictionary2 variables) in C:\BuildAgent\work\b5c671f6c6f2b660\source\Octopus.Core\Initialization\DatabaseUpgrader.cs:line 333
at DbUp.Engine.UpgradeEngine.PerformUpgrade()
ClientConnectionId:d06a97ac-8c0a-4c9b-9769-598232f7fae5
Error Number:3701,State:5,Class:11
2021-03-19 13:05:01.7316 7172 1 FATAL We encountered an error during the schema upgrade. The schema upgrade was stopped and rolled back. Don’t worry, this means we haven’t made any changes to your data, and you should be able to get back up and running quickly.

Regards,
Praneeth.

Hi @praneeth.reddy

Thanks for getting in touch! Sorry to hear that you’ve had an issue during the upgrade process.

This looks like it could be an SQL permission error during the upgrade process. Could you confirm if the user running the upgrade also has the db_owner permission on the SQL database? You can read more about the required permissions here.

Please let me know how you get on!

Hi Stuart,

Thanks for replying. The user has db_owner permission. But it is still throwing the same error.

Regards,
Praneeth.

This issue was resolved over email. For anyone arriving here after searching for a similar issue - this was caused by some missing tables in the database. The solution was to recreate the missing tables and then the upgrade completed successfully.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.