PK error when deploying

I’m trying to deploy one of my projects and getting the following SQL error indicating a PK violation:

 Error while executing SQL command in transaction 'http://octopus.numotion.com/octopus/api/deployments e8fbcabb6e6d443ca3b77e265ad25cd0': Violation of PRIMARY KEY constraint 'PK_Deployment_Id'. Cannot insert duplicate key in object 'dbo.Deployment'. The duplicate key value is (Deployments-4580). The statement has been terminated. The command being executed was: INSERT INTO dbo.[Deployment] (Name, Created, EnvironmentId, ProjectId, ReleaseId, ProjectGroupId, TaskId, ChannelId, TenantId, DeployedBy, DeployedToMachineIds, Id, JSON) values (@Name, @Created, @EnvironmentId, @ProjectId, @ReleaseId, @ProjectGroupId, @TaskId, @ChannelId, @TenantId, @DeployedBy, @DeployedToMachineIds, @Id, @JSON) SQL Error 2627 - Violation of PRIMARY KEY constraint 'PK_Deployment_Id'. Cannot insert duplicate key in object 'dbo.Deployment'. The duplicate key value is (Deployments-4580). The statement has been terminated.

I found a similar topic regarding the EventRelatedDocument table.* Unfortunately, this isn’t a simple INT IDENTITY, so I don’t think the solution there would apply directly. How can I stop this error occurring?

*Violation of PRIMARY KEY constraint 'PK_EventRelatedDocument'. Cannot insert duplicate key in object 'dbo.EventRelatedDocument'. The duplicate key value is (78614). The statement has been terminated

Hi Peter,

Thanks for getting in touch. To help with the troubleshooting could I get some more details about your deployment?

Are you deploying manually or from a build step or some other trigger? Could you attached any further details from where you see the error (there’ll usually be a stack trace and that would be useful to help us track potential causes).

Which version of Octopus are you using?

Regards
Shannon

Hi, Shannon – Thanks for responding.

I’m promoting manually from our Integration testing environment to our QA environment. But it looks like it’s a non-issue now; after Iand another dev tried several times yesterday, our QA lead kicked off the deployment successfully this morning. Was it specific to her or because some cleanup process ran overnight? We may never know, and if it doesn’t happen again, we won’t worry about it.

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