Migrations `sentry.0640_index_together` fails
Environment
self-hosted (https://develop.sentry.dev/self-hosted/)
Steps to Reproduce
- Checkout the nightly self-hosted repo into an existing project
- Run
install.sh
Expected Result
Upgrade runs successfully
Actual Result
Upgrade fails in migration sentry.0640_index_together with the error below. This is caused by this following migration step which calls RenameIndex, which fails because two indices exist on these columns: one created by index_together as well as one created by unique_together.
This is a django bug that is fixed with this django commit. After applying this commit into our sentry installation, the migration ran successfully.
Traceback (most recent call last):
File "/usr/local/bin/sentry", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/__init__.py", line 190, in main
func(**kwargs)
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/decorators.py", line 29, in inner
return ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/commands/django.py", line 14, in django
execute_from_command_line(argv=[ctx.command_path] + list(management_args))
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/monkey/executor.py", line 140, in apply_migration
return super().apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/migrations.py", line 22, in apply
return super().apply(project_state, schema_editor, collect_sql)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 1042, in database_forwards
raise ValueError(
ValueError: Found wrong number (2) of indexes for sentry_groupedmessage(project_id, id).
Product Area
Unknown
Link
No response
DSN
No response
Version
nightly
Assigning to @getsentry/support for routing ⏲️
I got this issue with this event id
ee4e9e869ab6a19f443f9b338159211c
+1 got the same error. My sentry envelope id is: ee4e9e869ab6a19f443f9b338159211c
Is it even possible to install Sentry at the moment?
Is there any workaround?
This is an index migration, it may impact performances but it looks like you can launch sentry without this migration as long as there are no structural migrations after.
Or even better, instead of running on master (nightly) branch, you may go to a tag and use a stable release: https://github.com/getsentry/self-hosted/tags
This seems to be due to this PR here: https://github.com/getsentry/sentry/pull/64158
In SaaS, it looks like this was due to some dangerous migrations not being performed. These can be performed manually and you can get these migrations with
git log -G thetablename -- src/sentry/migrations
Or, you can opt for a more hacky fix that I tried by going into your postgres database.
SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';
DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_idx;
CREATE INDEX sentry_grou_project_41a5ce_idx ON public.sentry_groupedmessage USING btree (project_id, id);
Or, you can opt for a more hacky fix that I tried by going into your postgres database.
SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage'; DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_idx; CREATE INDEX sentry_grou_project_41a5ce_idx ON public.sentry_groupedmessage USING btree (project_id, id);
This hack does not work for me.
@Christophe31 I feel so stupid, I did try to downgrade to a release tag but I forgot to update my .env.custom. Thank you!
Hey folks, we've recently upgraded our nightly image to django 5. Could you do us a favor and try upgrading again to see if you get the same error?
We think that this may be resolved as django 5 should pick up https://github.com/django/django/commit/70456610694d24d07d76c64fd3bc40f664be51ea
@hubertdeng123 Pulled the latest master branch details and ran the install.sh command, no luck, same error message.
I'm also still seeing this error with current master
+1, I had to comment DB upgrade line to finish install script.
We're working on a fix, which we will try to get out before the next release.
Could you folks try
SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';
DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_idx;
without recreating the index to see if the migration succeeds? Thinking about adding that to the 24.2.0 release as a workaround for this.
Gave it a shot, has no impact to the issue I am seeing.
sentry=# SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';
DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_idx;
indexname | indexdef
-------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------
sentry_groupedmessage_pkey | CREATE UNIQUE INDEX sentry_groupedmessage_pkey ON public.sentry_groupedmessage USING btree (id)
sentry_groupedmessage_project_id_short_id_29374dd7_uniq | CREATE UNIQUE INDEX sentry_groupedmessage_project_id_short_id_29374dd7_uniq ON public.sentry_groupedmessage USING btree (project_id, short_id)
sentry_groupedmessage_active_at_229e5298 | CREATE INDEX sentry_groupedmessage_active_at_229e5298 ON public.sentry_groupedmessage USING btree (active_at)
sentry_groupedmessage_first_release_id_c8ed807e | CREATE INDEX sentry_groupedmessage_first_release_id_c8ed807e ON public.sentry_groupedmessage USING btree (first_release_id)
sentry_groupedmessage_first_seen_a093f2c2 | CREATE INDEX sentry_groupedmessage_first_seen_a093f2c2 ON public.sentry_groupedmessage USING btree (first_seen)
sentry_groupedmessage_last_seen_d9c87974 | CREATE INDEX sentry_groupedmessage_last_seen_d9c87974 ON public.sentry_groupedmessage USING btree (last_seen)
sentry_groupedmessage_level_c2574e37 | CREATE INDEX sentry_groupedmessage_level_c2574e37 ON public.sentry_groupedmessage USING btree (level)
sentry_groupedmessage_logger_993cb6d5 | CREATE INDEX sentry_groupedmessage_logger_993cb6d5 ON public.sentry_groupedmessage USING btree (logger)
sentry_groupedmessage_logger_993cb6d5_like | CREATE INDEX sentry_groupedmessage_logger_993cb6d5_like ON public.sentry_groupedmessage USING btree (logger varchar_pattern_ops)
sentry_groupedmessage_project_id_9a5ae474 | CREATE INDEX sentry_groupedmessage_project_id_9a5ae474 ON public.sentry_groupedmessage USING btree (project_id)
sentry_grou_project_4662d9_idx | CREATE INDEX sentry_grou_project_4662d9_idx ON public.sentry_groupedmessage USING btree (project_id, first_release_id)
sentry_groupedmessage_project_id_id_515aaa7e_uniq | CREATE UNIQUE INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq ON public.sentry_groupedmessage USING btree (project_id, id)
sentry_grou_project_81a5ed_idx | CREATE INDEX sentry_grou_project_81a5ed_idx ON public.sentry_groupedmessage USING btree (project_id, status, last_seen, id)
sentry_groupedmessage_resolved_at_2c6a22d0 | CREATE INDEX sentry_groupedmessage_resolved_at_2c6a22d0 ON public.sentry_groupedmessage USING btree (resolved_at)
sentry_groupedmessage_status_028c2fe8 | CREATE INDEX sentry_groupedmessage_status_028c2fe8 ON public.sentry_groupedmessage USING btree (status)
sentry_groupedmessage_times_seen_03d64079 | CREATE INDEX sentry_groupedmessage_times_seen_03d64079 ON public.sentry_groupedmessage USING btree (times_seen)
sentry_groupedmessage_project_id_type_status_l_074196b6_idx | CREATE INDEX sentry_groupedmessage_project_id_type_status_l_074196b6_idx ON public.sentry_groupedmessage USING btree (project_id, status, type, last_seen, id)
sentry_groupedmessage_type_de66b3a2 | CREATE INDEX sentry_groupedmessage_type_de66b3a2 ON public.sentry_groupedmessage USING btree (type)
sentry_grou_project_ff3fdf_idx | CREATE INDEX sentry_grou_project_ff3fdf_idx ON public.sentry_groupedmessage USING btree (project_id, status, substatus, type, last_seen, id)
sentry_grou_project_5eb75b_idx | CREATE INDEX sentry_grou_project_5eb75b_idx ON public.sentry_groupedmessage USING btree (project_id, status, substatus, last_seen, id)
sentry_grou_project_5acaf7_idx | CREATE INDEX sentry_grou_project_5acaf7_idx ON public.sentry_groupedmessage USING btree (project_id, status, substatus, id)
sentry_grou_status_48b516_idx | CREATE INDEX sentry_grou_status_48b516_idx ON public.sentry_groupedmessage USING btree (status, substatus, id)
sentry_grou_status_e07f40_idx | CREATE INDEX sentry_grou_status_e07f40_idx ON public.sentry_groupedmessage USING btree (status, substatus, first_seen)
sentry_grou_project_41a5ce_idx | CREATE INDEX sentry_grou_project_41a5ce_idx ON public.sentry_groupedmessage USING btree (project_id, id)
(24 rows)
ERROR: index "sentry_groupedmessage_project_id_id_515aaa7e_idx" does not exist
$ docker exec -it $(docker ps | grep sentry_web | awk '{print $NF}') sentry upgrade
Running migrations for default
Operations to perform:
Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, sessions, sites, social_auth
Running migrations:
Applying sentry.0640_index_together...Traceback (most recent call last):
File "/usr/local/bin/sentry", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/__init__.py", line 190, in main
func(**kwargs)
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/decorators.py", line 29, in inner
return ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/commands/upgrade.py", line 121, in upgrade
_upgrade(
File "/usr/local/lib/python3.11/site-packages/sentry/runner/commands/upgrade.py", line 56, in _upgrade
dj_call_command(
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 194, in call_command
return command.execute(*args, **defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/monkey/executor.py", line 140, in apply_migration
return super().apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/migrations.py", line 22, in apply
return super().apply(project_state, schema_editor, collect_sql)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 1050, in database_forwards
raise ValueError(
ValueError: Found wrong number (2) of indexes for sentry_groupedmessage(project_id, id).
I'm also getting the same SQL error when attempting to run that workaround.
@nepeat @tankerkiller125 Hmmm, can you also try dropping sentry_groupedmessage_project_id_id_515aaa7e_uniq?
dropping sentry_groupedmessage_project_id_id_515aaa7e_uniq did the trick!
sentry=# drop index sentry_groupedmessage_project_id_id_515aaa7e_uniq;
DROP INDEX
$ docker exec -it $(docker ps | grep sentry_web | awk '{print $NF}') sentry upgrade
Running migrations for default
Operations to perform:
Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, sessions, sites, social_auth
Running migrations:
Applying sentry.0640_index_together... OK
Grouped Messages: 100% |###################################################################################################################################################| Time: 0:00:00
OK
Applying sentry.0642_index_together_release... OK
Applying sentry.0643_add_date_modified_col_dashboard_widget_query... OK
Creating missing DSNs
Correcting Group.num_comments counter
18:48:42 [INFO] sentry.outboxes: Executing outbox replication backfill
18:48:42 [INFO] sentry.outboxes: Processing sentry.ControlOutboxs...
18:48:42 [INFO] sentry.outboxes: Processing sentry.RegionOutboxs...
18:48:42 [INFO] sentry.outboxes: done
Awesome :)
I can also confirm that it works now after dropping that index.
I don't think this index should be there:
sentry_groupedmessage_project_id_id_515aaa7e_uniq, judging from a clean setup of a postgres database and migrations. I'll put up a PR to address this.
@hubertdeng123 hi, just upgraded from 24.1.1 to 24.1.2, and the install step always exits on
Error in install/set-up-and-migrate-database.sh:5.
'timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done"' exited with status 124
-> ./install.sh:main:35
--> install/set-up-and-migrate-database.sh:source:5
I don't have any custom config or plugins.
Sorry for posting it here and possibly confusing someone - it's the code supposed to fix this issue.
Same issue as @stepech
I've dropped the index sentry_groupedmessage_project_id_id_515aaa7e_uniq manually, removed the patch applied to install.shon 24.1.2, and the install finished
Hmmm interesting, we're not experiencing that issue when upgrading ourselves. Perhaps it might be safer to timeout 30s or so to account for different environments not being able to run
timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done? 🤔
Ah I think I was able to reproduce the issue. Putting together a fix...
While upgrade from 24.1.0 to 24.1.2, the pg_isready from the script command timeouts for me, while the pg_isready I un in a parallel terminal works just fine:
$ docker compose exec postgres pg_isready
/var/run/postgresql:5432 - accepting connections
On my end I replaced with a sleep to un-break my install:
diff --git a/install/set-up-and-migrate-database.sh b/install/set-up-and-migrate-database.sh
index 1b8adf7..8dfd071 100644
--- a/install/set-up-and-migrate-database.sh
+++ b/install/set-up-and-migrate-database.sh
@@ -2,7 +2,8 @@ echo "${_group}Setting up / migrating database ..."
# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue, and the migrations run just fine after that.
$dc up -d postgres
-timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done"
+sleep 30
+#timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done"
indexes=$($dc exec postgres psql -qAt -U postgres -c "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';")
if [[ $indexes == *"sentry_groupedmessage_project_id_id_515aaa7e_uniq"* ]]; then
$dc postgres psql -qAt -U postgres -c "DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
EDIT: #2779 looks a better way to do the retries indeed :)
I've dropped both sentry_groupedmessage_project_id_id_515aaa7e and sentry_groupedmessage_project_id_id_515aaa7e_uniq indexes, but the 640 migration still gives me that error:
ValueError: Found wrong number (2) of indexes for sentry_groupedmessage(project_id, id)
I'm stuck with the same error even after i removed the indexes sentry_groupedmessage_project_id_id_515aaa7e and sentry_groupedmessage_project_id_id_515aaa7e_uniq. Any idea to fix it ?
root@sentry-web-746c74cf75-ppl8x:/# sentry upgrade --noinput
Running migrations for default
Operations to perform:
Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, sessions, sites, social_auth
Running migrations:
Applying sentry.0640_index_together...Traceback (most recent call last):
File "/usr/local/bin/sentry", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/__init__.py", line 190, in main
func(**kwargs)
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/decorators.py", line 29, in inner
return ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/runner/commands/upgrade.py", line 121, in upgrade
_upgrade(
File "/usr/local/lib/python3.11/site-packages/sentry/runner/commands/upgrade.py", line 56, in _upgrade
dj_call_command(
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 194, in call_command
return command.execute(*args, **defaults)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/monkey/executor.py", line 140, in apply_migration
return super().apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sentry/new_migrations/migrations.py", line 22, in apply
return super().apply(project_state, schema_editor, collect_sql)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 1050, in database_forwards
raise ValueError(
ValueError: Found wrong number (2) of indexes for sentry_groupedmessage(project_id, id).
The table's indexes list:
postgres=# SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';
sentry_groupedmessage_pkey|CREATE UNIQUE INDEX sentry_groupedmessage_pkey ON public.sentry_groupedmessage USING btree (id)
sentry_groupedmessage_project_id_short_id_29374dd7_uniq|CREATE UNIQUE INDEX sentry_groupedmessage_project_id_short_id_29374dd7_uniq ON public.sentry_groupedmessage USING btree (project_id, short_id)
sentry_groupedmessage_active_at_229e5298|CREATE INDEX sentry_groupedmessage_active_at_229e5298 ON public.sentry_groupedmessage USING btree (active_at)
sentry_groupedmessage_first_release_id_c8ed807e|CREATE INDEX sentry_groupedmessage_first_release_id_c8ed807e ON public.sentry_groupedmessage USING btree (first_release_id)
sentry_groupedmessage_first_seen_a093f2c2|CREATE INDEX sentry_groupedmessage_first_seen_a093f2c2 ON public.sentry_groupedmessage USING btree (first_seen)
sentry_groupedmessage_last_seen_d9c87974|CREATE INDEX sentry_groupedmessage_last_seen_d9c87974 ON public.sentry_groupedmessage USING btree (last_seen)
sentry_groupedmessage_level_c2574e37|CREATE INDEX sentry_groupedmessage_level_c2574e37 ON public.sentry_groupedmessage USING btree (level)
sentry_groupedmessage_logger_993cb6d5|CREATE INDEX sentry_groupedmessage_logger_993cb6d5 ON public.sentry_groupedmessage USING btree (logger)
sentry_groupedmessage_logger_993cb6d5_like|CREATE INDEX sentry_groupedmessage_logger_993cb6d5_like ON public.sentry_groupedmessage USING btree (logger varchar_pattern_ops)
sentry_groupedmessage_project_id_9a5ae474|CREATE INDEX sentry_groupedmessage_project_id_9a5ae474 ON public.sentry_groupedmessage USING btree (project_id)
sentry_groupedmessage_project_id_first_release_id_7f8c0ae5_idx|CREATE INDEX sentry_groupedmessage_project_id_first_release_id_7f8c0ae5_idx ON public.sentry_groupedmessage USING btree (project_id, first_release_id)
sentry_groupedmessage_project_id_status_last_s_6b8195a7_idx|CREATE INDEX sentry_groupedmessage_project_id_status_last_s_6b8195a7_idx ON public.sentry_groupedmessage USING btree (project_id, status, last_seen, id)
sentry_groupedmessage_project_id_type_status_l_074196b6_idx|CREATE INDEX sentry_groupedmessage_project_id_type_status_l_074196b6_idx ON public.sentry_groupedmessage USING btree (project_id, status, type, last_seen, id)
sentry_groupedmessage_resolved_at_2c6a22d0|CREATE INDEX sentry_groupedmessage_resolved_at_2c6a22d0 ON public.sentry_groupedmessage USING btree (resolved_at)
sentry_groupedmessage_status_028c2fe8|CREATE INDEX sentry_groupedmessage_status_028c2fe8 ON public.sentry_groupedmessage USING btree (status)
sentry_groupedmessage_times_seen_03d64079|CREATE INDEX sentry_groupedmessage_times_seen_03d64079 ON public.sentry_groupedmessage USING btree (times_seen)
sentry_groupedmessage_type_de66b3a2|CREATE INDEX sentry_groupedmessage_type_de66b3a2 ON public.sentry_groupedmessage USING btree (type)
Looks exactly like my situation