getsentry / self-hosted

Sentry, feature-complete and packaged up for low-volume deployments and proofs-of-concept
https://develop.sentry.dev/self-hosted/
Other
7.7k stars 1.74k forks source link

Postgres issue while upgrading #3014

Closed hubertdeng123 closed 2 months ago

hubertdeng123 commented 4 months ago

Self-Hosted Version

24.4.2

CPU Architecture

x86_64

Docker Version

n/a

Docker Compose Version

n/a

Steps to Reproduce

Upgrading to 24.4.2+ is giving some users issues. This is taken from discord

  1. ./install.sh
  2. See error below
    Running migrations for default
    Operations to perform:
    Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, sessions, sites, social_auth
    Running migrations:
    Alert Rules: 100% |#                                           | ETA:  --:--:--
    OK
    Applying sentry.0702_alert_rule_project_backfill_migration_2... OK
    Applying sentry.0703_add_team_user_to_rule... OK
    Rules: 100% |##################################################| Time:  0:00:00
    OK
    Applying sentry.0705_grouphistory_add_userteam... OK
    Group Historys: 100% |#########################################| Time:  0:00:00
    OK
    Applying sentry.0707_alert_rule_activations_incidents_fk... OK
    Applying sentry.0708_rule_remove_owner_state... OK
    Creating missing DSNs
    Correcting Group.num_comments counter
    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/site-packages/sentry/db/postgres/decorators.py", line 91, in inner
    return func(self, sql, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/site-packages/sentry/db/postgres/base.py", line 84, in execute
    return self.cursor.execute(sql, clean_bad_params(params))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    psycopg2.errors.IndexCorrupted: table tid from new index tuple (20,3) overlaps with invalid duplicate tuple at offset 7 of block 8 in index "sentry_groupedmessage_logger_993cb6d5"

Expected Result

no error

Actual Result

error

Event ID

No response

hubertdeng123 commented 4 months ago

Possible solution from Friberg on discord:

https://discord.com/channels/621778831602221064/796028405833007104/1235624852564611106

aldy505 commented 4 months ago

Didn't encountered the migration error when not using the alpine image (meaning continue using the debian image)

diff --git a/docker-compose.yml b/docker-compose.yml
index 9cc58dd..cb800ad 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -132,7 +132,7 @@ services:
   postgres:
     <<: *restart_policy
     # Using the same postgres version as Sentry dev for consistency purposes
-    image: "postgres:14.11-alpine"
+    image: "postgres:14.11"
     healthcheck:
       <<: *healthcheck_defaults
       # Using default user "postgres" from sentry/sentry.conf.example.py or value of POSTGRES_USER if provided
tm1000 commented 2 months ago

What @aldy505 posted worked for me as well

note you can create a docker.override.yml file instead of editing docker-compose.yml directly (which is tracked)

docker.override.yml

services:
    postgres:
      # https://github.com/getsentry/self-hosted/issues/3014
      image: "postgres:14.11"

Ref: #3027

hubertdeng123 commented 2 months ago

Going to close this due to https://github.com/getsentry/self-hosted/pull/3116