After upgrading to version 2022.1 (Build 2278), we have started getting this error a lot across different tasks (creating releases, triggering health checks or calamari update via the API, registering tentacles etc). It might also be relevant that we changed our installation from a single server node to two nodes with shared storage as a part of this upgrade.
The full error message typically looks something like this:
[Octopus Deploy] Octopus Server returned an error: Error while executing SQL command in transaction 'CreateDeployment.Create|80001141-0002-ad00-b63f-84710c7967bb|T250': The INSERT statement conflicted with the FOREIGN KEY constraint "FK_EventRelatedDocument_EventId". The conflict occurred in database "octopus", table "dbo.Event", column 'Id'.
The error message is pretty much identical in all cases, except for the GUID and the name of the transaction (CreateDeployment.Create
, CreateTask.CreateTask
, /api/(?<baseSpaceId>Spaces-\d+)/machines
, etc).
In some cases it seems to be related to these tasks being triggered from multiple sources in parallel, and it goes away if we force them to trigger sequentially. But this is not feasible to do in every case, since we run a lot of deployments across different teams every day, and they mostly manage their own Octopus tentacles.
Weāre also seeing this error a lot in the server log, and are not sure if itās related:
An error occurred while trying to trying fetch the number of active SQL transactions: "Error while executing SQL command in transaction 'SqlTransactionMetricsProducer.UpdateMetrics': VIEW SERVER STATE permission was denied on object 'server', database 'master'.
The user does not have permission to perform this action.
The command being executed was:
SELECT COUNT(*) FROM sys.dm_tran_active_transactions" System.Exception: Error while executing SQL command in transaction 'SqlTransactionMetricsProducer.UpdateMetrics': VIEW SERVER STATE permission was denied on object 'server', database 'master'.
The user does not have permission to perform this action.
The command being executed was:
SELECT COUNT(*) FROM sys.dm_tran_active_transactions
Is there anything we can do to mitigate this?