Primary key constraint error while trying to add or update any entity (such as deployment process, environment etc)

Sodiq Yusuf's Avatar

Sodiq Yusuf

12 Sep, 2017 07:45 AM

So we moved our octopus database to another server but after doing this, we could not add or update an environment, deployment process or any other thing again. I have attached the screenshot of this issue. I would be so glad to receive a response as soon as possible as this issue is causing a serious downtime in our operations. I am running Octopus 3.12.7
Thanks

  1. 1 Posted by Vanessa Love on 13 Sep, 2017 04:32 AM

    Vanessa Love's Avatar

    Hi,

    Sorry that you have run into this issue. It occurs when your Event index ID is behind. We aren't sure why this occurs but we have seen it once before.

    You will need to complete the following to reset the ID:

    1. Shutdown Octopus Deploy (stop the service)
    2. Create a full backup of the database
    3. Run the following SQL (you may want to download SQL Server Management Studio from https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-manag... to run the script):
      DECLARE @maxVal INT
      SELECT @maxVal = ISNULL(max(ID),0)+1 from octopus.dbo.EventRelatedDocument
      DBCC CHECKIDENT('octopus.dbo.EventRelatedDocument', RESEED, @maxVal)
      

    Please let me know if that helps.
    Vanessa

  2. 2 Posted by Sodiq Yusuf on 13 Sep, 2017 09:28 AM

    Sodiq Yusuf's Avatar

    Thank you so much, Vanessa, it now works after running that script.

  3. 3 Posted by Vanessa Love on 14 Sep, 2017 04:49 AM

    Vanessa Love's Avatar

    Hi,

    Glad to hear that fixed the issue. As i'm sure you can understand this isn't something we want to ever occur, and we would like to investigate how it occurred.
    Are you at all willing to provide us with your database backup? I can provide a secure location to upload it, and we do not require the masterkey thus won't be able to see any secure information.

    Please let me know.
    Vanessa

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • octopus_error_screenshot.PNG 113 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac