Sentry Upgrade from 21.6.1 to 21.6.2

Greetings,

While attempting to upgrade from on-premise Sentry v21.6.1 to v21.6.2 on a CentOS Linux release 7.9.2009 EC2 instance in AWS, I encountered the following error during the execution of ./install.sh:

...
Running migrations for default
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, jira_ac, nodestore, sentry, sessions, sites, social_auth
Running migrations:
  Applying sentry.0208_add_team_scope... OK
  Applying sentry.0209_avatar_remove_file_fk... OK
Organization Options: 100% |#####################################| Time: 0:00:00
 OK
  Applying sentry.0211_add_artifact_count... OK
  Applying sentry.0212_appconnectbuilds... OK
  Applying sentry.0213_rule_project_status_owner_index... OK
  Applying sentry.0214_activity_project_type_datetime_idx... OK
  Applying sentry.0215_fix_state... OK
  Applying sentry.0216_cdc_setup_replication_index...Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 91, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/base.py", line 76, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: index "sentry_groupasignee_project_id_group_id_fbf4364e_uniq" for table "sentry_groupasignee" does not exist

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 77, in inner
    raise_the_exception(self.db, e)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 75, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 18, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 95, in inner
    raise exc_info[0](msg).with_traceback(exc_info[2])
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 91, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/base.py", line 76, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: ProgrammingError('index "sentry_groupasignee_project_id_group_id_fbf4364e_uniq" for table "sentry_groupasignee" does not exist\n',)
SQL:
            ALTER TABLE sentry_groupasignee REPLICA IDENTITY USING INDEX
            sentry_groupasignee_project_id_group_id_fbf4364e_uniq


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/sentry", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/sentry/runner/__init__.py", line 196, in main
    func(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/runner/decorators.py", line 29, in inner
    return ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py", line 68, in upgrade
    _upgrade(not noinput, traceback, verbosity, not no_repair, with_nodestore)
  File "/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py", line 24, in _upgrade
    ignore_ghost_migrations=True,
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 131, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.6/site-packages/sentry/new_migrations/monkey/executor.py", line 77, in apply_migration
    return super().apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/operations/special.py", line 108, in database_forwards
    self._run_sql(schema_editor, self.sql)
  File "/usr/local/lib/python3.6/site-packages/django/db/migrations/operations/special.py", line 133, in _run_sql
    schema_editor.execute(statement, params=None)
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 136, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.6/site-packages/sentry_sdk/integrations/django/__init__.py", line 500, in execute
    return real_execute(self, sql, params)
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 77, in inner
    raise_the_exception(self.db, e)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 75, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 18, in inner
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 95, in inner
    raise exc_info[0](msg).with_traceback(exc_info[2])
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py", line 91, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sentry/db/postgres/base.py", line 76, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: ProgrammingError('index "sentry_groupasignee_project_id_group_id_fbf4364e_uniq" for table "sentry_groupasignee" does not exist\n',)
SQL:
            ALTER TABLE sentry_groupasignee REPLICA IDENTITY USING INDEX
            sentry_groupasignee_project_id_group_id_fbf4364e_uniq

1
An error occurred, caught SIGERR on line 12
Cleaning up...

A query of the indexes in the database yields:

SELECT tablename, indexname, indexdef FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'sentry_groupasignee' ORDER BY tablename, indexname;
tablename	indexname	indexdef
sentry_groupasignee	sentry_groupasignee_group_id_key	CREATE UNIQUE INDEX sentry_groupasignee_group_id_key ON public.sentry_groupasignee USING btree (group_id)
sentry_groupasignee	sentry_groupasignee_pkey	CREATE UNIQUE INDEX sentry_groupasignee_pkey ON public.sentry_groupasignee USING btree (id)
sentry_groupasignee	sentry_groupasignee_project_id	CREATE INDEX sentry_groupasignee_project_id ON public.sentry_groupasignee USING btree (project_id)
sentry_groupasignee	sentry_groupasignee_project_id_fbf4364e_uniq	CREATE UNIQUE INDEX sentry_groupasignee_project_id_fbf4364e_uniq ON public.sentry_groupasignee USING btree (project_id, group_id)
sentry_groupasignee	sentry_groupasignee_team_id	CREATE INDEX sentry_groupasignee_team_id ON public.sentry_groupasignee USING btree (team_id)
sentry_groupasignee	sentry_groupasignee_user_id	CREATE INDEX sentry_groupasignee_user_id ON public.sentry_groupasignee USING btree (user_id)

Why is it that this index – sentry_groupasignee_project_id_group_id_fbf4364e_uniq – does not already exist and how do I mitigate it so I can successfully upgrade the install?

Thanks in advance.

Hi, sorry for the trouble. This issue is known to exist in versions prior to 21.6.3. You need to upgrade to 21.6.3 which should work. Then you can also upgrade to newer versions like 21.7.0.

1 Like

Thanks for the quick reply and solution. I performed the upgrade from 21.6.1 to 21.6.3 and it succeeded this time:

...
Running migrations for default
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, jira_ac, nodestore, sentry, sessions, sites, social_auth
Running migrations:
  Applying sentry.0216_cdc_setup_replication_index... OK
  Applying sentry.0217_debugfile_remove_project_fk... OK
  Applying sentry.0218_releasefile_remove_fks... OK
  Applying sentry.0219_exporteddatablob_remove_blob_fk... OK
Creating missing DSNs
Correcting Group.num_comments counter

▶ Migrating file storage ...

▶ Generating Relay credentials ...
../relay/config.yml already exists, skipped creation.

▶ Setting up GeoIP integration ...
Setting up IP address geolocation ...
IP address geolocation database already exists.
IP address geolocation is configured for updates.
Updating IP address geolocation database ...
--no-ansi option is deprecated and will be removed in future versions. Use `--ansi never` instead.
Creating sentry_onpremise_geoipupdate_run ...
Creating sentry_onpremise_geoipupdate_run ... done
Done updating IP address geolocation database.
Done setting up IP address geolocation.


-----------------------------------------------------------------

You're all done! Run the following command to get Sentry running:

  docker-compose up -d

-----------------------------------------------------------------

#

I will attempt to upgrade to v21.7.0 after I allow Sentry to settle awhile.

1 Like

@BYK , I successfully upgraded from v21.6.1 → 21.6.3 → 21.7.0 following your recommendation to skip v21.6.2 to avoid the missing index reference.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.