Creating new releases via sentry-cli creates several identical releases

Important Details

How are you running Sentry?

On-Premise w/ Docker, version 19.03.13
Sentry version: Sentry 20.10.178833d9
Sentry-CLI version: 1.58

Description

Hello everyone,
I’m not really familiar with Sentry yet, but I’ve updated from Sentry 9.1.2 to Sentry 20.10 at our company.
After the update the users complained that they are no longer able to upload source maps. In response they get a HTTP Error 500 from the server.
While analyzing the problem I noticed that the releases are created multiple times with the same release number and afterwards the release can’t be accessed anymore.
New releases are created via CI/CD pipeline from Gitlab with sentry-cli.
Also in the UI the releases can not be accessed anymore.

web_1 | 172.18.0.12 - - [03/Nov/2020:19:54:51 +0000] "POST /api/0/relays/projectconfigs/?version=2 HTTP/1.1" 200 2460 "-" "actix-web/0.7.19" web_1 | 19:54:52 [INFO] sentry.superuser: superuser.request (user_id=72 url=u'http://sentry.somedomain.de/api/0/organizations/ACME/releases/8b365992/meta/' method=u'GET' ip_address=u'172.18.0.1') web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python2.7/site-packages/sentry/api/base.py", line 124, in handle_exception web_1 | response = super(Endpoint, self).handle_exception(exc) web_1 | File "/usr/local/lib/python2.7/site-packages/rest_framework/views.py", line 449, in handle_exception web_1 | self.raise_uncaught_exception(exc) web_1 | File "/usr/local/lib/python2.7/site-packages/sentry/api/base.py", line 237, in dispatch web_1 | response = handler(request, *args, **kwargs) web_1 | File "/usr/local/lib/python2.7/site-packages/sentry/api/endpoints/organization_release_meta.py", line 35, in get web_1 | release = Release.objects.get(organization_id=organization.id, version=version) web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method web_1 | return getattr(self.get_queryset(), name)(*args, **kwargs) web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 384, in get web_1 | (self.model._meta.object_name, num) web_1 | MultipleObjectsReturned: get() returned more than one Release -- it returned 2! web_1 | 172.18.0.25 - - [03/Nov/2020:19:54:52 +0000] "GET /api/0/organizations/ACME/releases/8b365992/meta/ HTTP/1.1" 500 731 "https://sentry.somedomain.de/organizations/ACME/releases/8b365992/?project=49" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" web_1 | 19:54:52 [INFO] sentry.superuser: superuser.request (user_id=72 url=u'http://sentry.somedomain.de/api/embed/error-page/?dsn=https://b5eeb9459fb04deab3f548163e4c9ad3@sentry.somedomain.de/1&eventId=cbc0437eb3414af9b284c8ef185af859&dsn=https%3A%2F%2Fb5eeb9459fb04deab3f548163e4c9ad3%40sentry.somedomain.de%2F1' method=u'GET' ip_address=u'172.18.0.1') web_1 | 172.18.0.25 - - [03/Nov/2020:19:54:52 +0000] "GET /api/embed/error-page/?dsn=https://b5eeb9459fb04deab3f548163e4c9ad3@sentry.somedomain.de/1&eventId=cbc0437eb3414af9b284c8ef185af859&dsn=https%3A%2F%2Fb5eeb9459fb04deab3f548163e4c9ad3%40sentry.somedomain.de%2F1 HTTP/1.1" 200 16252 "https://sentry.somedomain.de/organizations/ACME/releases/8b365992/?project=49" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" web_1 | 172.18.0.12 - - [03/Nov/2020:19:54:52 +0000] "POST /api/0/relays/projectconfigs/?version=2 HTTP/1.1" 200 2460 "-" "actix-web/0.7.19" web_1 | 172.18.0.25 - - [03/Nov/2020:19:54:53 +0000] "GET /_static/1603207865/sentry/dist/vendor.js.map HTTP/1.1" 200 1661625 "-" "sentry/20.10.1 (https://sentry.io)"

Steps to Reproduce

CI/CD build

function sentry() { local build_artifact=$1 VERSION=$(jq -r '.version' package.json) echo "Creating Sentry release. Version: ${VERSION}" retry sentry-cli releases new "$VERSION" retry sentry-cli releases files "$VERSION" upload-sourcemaps "$build_artifact" --rewrite retry sentry-cli releases finalize "$VERSION" }

Upgrade to Sentry 21.2. didn’t fix the Problem

There normally should be a unique constraint that prevents this from happening. I’m not sure how you would end up with multiple releases.

Can you show which data was inserted twice?

I guess the unique constraint should be the version, right?
I am attaching an export of the sentry_release table.