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

(Sodiq Yusuf) #1

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

(Vanessa Love) #2

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-management-studio-ssms 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

(Sodiq Yusuf) #3

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

(Vanessa Love) #4

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

(system) closed #5