getsentry / getsentry/self-hosted

ERROR: duplicate key value violates unique constraint

Open
#2,171 35 comments 0 reactions 1 assignee Claimed by @hubertdeng123 View on GitHub
Bug Type: Support Request
Dominant language
Shell
Stars
9.6k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
15

Description

### Self-Hosted Version

23.5.1

### CPU Architecture

x86_64

### Docker Version

24.0.2

### Docker Compose Version

2.18.1

### Steps to Reproduce

1. Upgrade Sentry from pre-postgres-14 version (i.e. 23.3.0) to latest version
2. Make sure there is a moderate amount of incoming events, and issues are being created
3. Check postgres container logs

### Expected Result

There should be no errors.

### Actual Result

A lot of errors like this:
```
ERROR: duplicate key value violates unique constraint "sentry_environmentprojec_project_id_environment_i_91da82f2_uniq"
DETAIL: Key (project_id, environment_id)=(175, 1) already exists.
STATEMENT: INSERT INTO "sentry_environmentproject" ("project_id", "environment_id", "is_hidden") VALUES (175, 1, NULL) RETURNING "sentry_environmentproject"."id"

ERROR: duplicate key value violates unique constraint "sentry_grouprelease_group_id_release_id_envi_044354c8_uniq"
DETAIL: Key (group_id, release_id, environment)=(5040920, 17693, production) already exists.
STATEMENT: INSERT INTO "sentry_grouprelease" ("project_id", "group_id", "release_id", "environment", "first_seen", "last_seen") VALUES (38, 5040920, 17693, 'production', '2023-06-01T11:40:07.927899+00:00'::timestamptz, '2023-06-01T11:40:07.927899+00:00'::timestamptz) RETURNING "sentry_grouprelease"."id"
```

### Event ID

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.