Migrations not working in 24.6.0 -> DuplicateObject('constraint "sentry_externalactor_actor_id_a8478274_fk_sentry_actor_id" for relation "sentry_externalactor" already exists\n')
Self-Hosted Version
24.6.0
CPU Architecture
x86_64
Docker Version
Docker version 26.1.4, build 5650f9b
Docker Compose Version
Docker Compose version v2.27.1
Steps to Reproduce
Take a normal 23.6.2 version, fully working, and try to upgrade to 24.6.0. When running migrations, the system crashes
Expected Result
System building correctly
Actual Result
DuplicateObject('constraint "sentry_externalactor_actor_id_a8478274_fk_sentry_actor_id" for relation "sentry_externalactor" already exists\n')
`Running migrations for default Operations to perform: Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, ses Running migrations: Applying sentry.0551_drop_xactor_actor...Traceback (most recent call last): File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 91, in inner return func(self, sql, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/sentry/src/sentry/db/postgres/base.py", line 85, in execute return self.cursor.execute(sql) ^^^^^^^^^^^^^^^^^^^^^^^^ psycopg2.errors.DuplicateObject: constraint "sentry_externalactor_actor_id_a8478274_fk_sentry_acto
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/.venv/lib/python3.11/site-packages/django/db/backends/utils.py", line 103, in execute return self.cursor.execute(sql) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 77, in inner raise_the_exception(self.db, e) File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 75, in inner return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 18, in inner return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 93, in inner raise type(e)(f"{e!r}\nSQL: {sql}").with_traceback(e.traceback) File "/usr/src/sentry/src/sentry/db/postgres/decorators.py", line 91, in inner return func(self, sql, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/sentry/src/sentry/db/postgres/base.py", line 85, in execute return self.cursor.execute(sql) ^^^^^^^^^^^^^^^^^^^^^^^^ psycopg2.errors.DuplicateObject: DuplicateObject('constraint "sentry_externalactor_actor_id_a84782 SQL: ALTER TABLE "sentry_externalactor" ADD CONSTRAINT "sentry_externalactor_actor_id_a8478274_fk
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/.venv/bin/sentry", line 4, in
`
Event ID
No response
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Usage: sentry upgrade [OPTIONS]
Try 'sentry upgrade --help' for help.
Error: No such option: --create-kafka-topics
Error in install/set-up-and-migrate-database.sh:30.
'$dcr web upgrade --create-kafka-topics' exited with status 2
-> ./install.sh:main:38
--> install/set-up-and-migrate-database.sh:source:30
Cleaning up...
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Usage: sentry upgrade [OPTIONS] Try 'sentry upgrade --help' for help. Error: No such option: --create-kafka-topics Error in install/set-up-and-migrate-database.sh:30. '$dcr web upgrade --create-kafka-topics' exited with status 2 -> ./install.sh:main:38 --> install/set-up-and-migrate-database.sh:source:30 Cleaning up...
I forgot to update the versions in my .env.custom file to 24.6.0
It seems like it is attempting to run the migrations twice. What if you use ./sentry-admin.sh django migrate as a standalone command, then try again?
I'm in the process of updating an instance that has been updated last in august 2023. I had to run:
ALTER TABLE sentry_externalactor
DROP CONSTRAINT sentry_externalactor_actor_id_a8478274_fk_sentry_actor_id;
I think I find myself in a similar situation. I followed the hard-stop versions here when upgrading – but didn't upgrade docker or docker-compose at any point during this. I think this then caused some issues when I later did upgrade docker-compose to 2+ and saw that the migrations only ran after this (By then I was already on the latest sentry version) – so think I missed some migration steps.
We did bump the docker compose version in the last year or so. @thedevale were you able to figure out a solution here? Perhaps it may be helpful to upgrade to an intermediate version of Sentry before going to latest...we may have missed documenting some sort of hard stop in the upgrade process.
I had similar issues, got a
Usage: sentry upgrade [OPTIONS]
Try 'sentry upgrade --help' for help.
Error: No such option: --create-kafka-topics
Error in install/set-up-and-migrate-database.sh:30.
'$dcr web upgrade --create-kafka-topics' exited with status 2
-> ./install.sh:main:38
--> install/set-up-and-migrate-database.sh:source:30
when running ./install.sh.
Problem was that copying 24.6 dir contents over my current 23.12 dir, did not copy .env file (cp -r ../24.6/* .)
After copying that file over, the install.sh did complete succesfully.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀