SQL error

Hi,

I am not able to deploy the solution on my server.

It stops after

Error: Beginning transaction
Error: Checking whether journal table exists…
Error: Journal table does not exist
Error: Executing TSQL Database Server script ‘Octopus.Core.UpgradeScripts.Script0000 - Fix wrong schema.sql’
Error: Checking whether journal table exists…
Error: Creating the [dbo].[SchemaVersions] table
Error: The [dbo].[SchemaVersions] table has been created
Error: Executing TSQL Database Server script ‘Octopus.Core.UpgradeScripts.Script0001 - Initial schema.sql’
Error: SQLException has occured in statement #0 of this TSQL script: ‘Octopus.Core.UpgradeScripts.Script0001 - Initial schema.sql’; Line: 94; Procedure: ; Error Number: 2714; Excerpt: ‘CREATE TABLE [dbo].[Event] (’; Message: There is already an object named ‘Event’ in the database.
Error: Error occured when executing scripts, transaction will be rolled back
Error: Upgrade failed due to an unexpected exception:
Error: System.Data.SqlClient.SqlException (0x80131904): There is already an object named ‘Event’ in the database.
Error: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) Error: at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) Error: at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) Error: at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() Error: at System.Data.SqlClient.SqlDataReader.get_MetaData() Error: at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) Error: at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) Error: at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
Error: at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
Error: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
Error: at DbUp.Support.ScriptExecutor.ExecuteAndLogOutput(IDbCommand command)
Error: at Octopus.Core.Initialization.DatabaseUpgrader.OctopusUpgradeScriptExecutor.<>c__DisplayClass7_0.b__0(Func1 commandFactory) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Core\Initialization\DatabaseUpgrader.cs:line 360 Error: at DbUp.Engine.Transactions.SingleTrasactionStrategy.Execute(Action1 action)
Error: at Octopus.Core.Initialization.DatabaseUpgrader.OctopusUpgradeScriptExecutor.Execute(SqlScript script, IDictionary`2 variables) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Core\Initialization\DatabaseUpgrader.cs:line 291
Error: at DbUp.Engine.UpgradeEngine.PerformUpgrade()
Error: ClientConnectionId:89d193de-b998-41ea-8c05-fb735e941a35
Error: Error Number:2714,State:6,Class:16
Error:
Error: -----------------------------------------
Error: You have two options from this point:
Error: OPTION 1: Re-run the installer for the version of Octopus Server you were using just before trying this upgrade. Your data hasn’t been changed and everything will go back to how it was beforehand. Please send this log to support@octopus.com and we will work with you to get you upgraded.
Error: OPTION 2: If you know what the problem is and how to fix it, please fix the problem and then try the upgrade again by running C:\Program Files\Octopus Deploy\Octopus\Octopus.Server.exe database --upgrade
Error:
Error: The previous command returned a non-zero exit code of: 1
Error: The command that failed was: “C:\Program Files\Octopus Deploy\Octopus\Octopus.Server.exe” database --instance “OctopusServer” --connectionString “Data Source=BTS2016VM;Initial Catalog=ReportServer;Integrated Security=True” --create --grant “NT AUTHORITY\SYSTEM”
Could not open the database. This instance was not removed from the database.
Deleted instance: OctopusServer

Hi @christophe.belouara,

Thanks for getting in touch! I will need to get some more information from you to get a better idea of what could be going wrong here.

Would you be able to provide some details on what you are trying to do? From the error, it looks like we are trying to run database upgrade scripts which have already been run. This suggests a possible issue with the database schema or another error.

Script0001 is trying to run, which is failing when attempting to create the events table, as this already exists.

Form the logs posted here it looks like you may be trying to run a database -create command with Octopus.Server.exe, where the database already exists. So I think it would help in our troubleshooting to get some more details about how you are encountering this error and what you are trying to.

Looking forward to hearing from you and getting to the bottom of this.

Best regards,
Daniel

Hi Daniel,

Yes, it looks
it is an upgrade because I’ve installed Octopus a few months ago but I didn’t get time to test it.

How can I
install from scratch?

I tried to
uninstall Octopus but I have the same error.

Hi Daniel,

For
your information I don’t have access to Octopus manager window.

The
only thing I have is

Hi @christophe.belouara,

Thanks for getting back. I think I know what may be going on here. So it looks like Octopus already has a database configured and you are trying to configure a new instance with this database. If the existing Octopus database has no data in it that you need to keep, you can delete the old database.

Once you remove the old database, you could try to work through the installer again from your screenshot. The Octopus instance creation will be able to create a new database for you if one does not exist.

Would you be able to try this and let me know if it resolves your issue?

Best regards,
Daniel

HI Daniel,

Which database
I should delete?

I mean what
it is its name?

Hi @christophe.belouara,

The name of the database will be the same as the database name you are entering when you attempt to create the new instance in Octopus.

As a note, this will remove all data relating to that Octopus instance.

Alternatively, if you have trouble removing the old database, try creating a new instance in Octopus and providing a NEW database name. This will have Octopus create the new database for you and should eliminate the issue you are encountering here.

Let me know how you go.

Best regards,
Daniel

Hi Daniel,

Now,
it works.

Thank
you.

1 Like