Skip to content

Migration Hard Stops inforcement #4511

Open

Description

@mhkarimi1383

Problem Statement

Hi

today I was upgrading a Sentry Self Hosted instance, But I was doing a wrong path,

I was expecting a meaning full error instead of a random error before running migration

Solution Brainstorm

Like what we have in GitLab, It should check before running migration and raise a meaningful error and don't start at all

Product Area

Unknown

Activity

  1. getsantry commented on Sep 14, 2026

    @getsantry

    Assigning to @getsentry/support for routing ⏲️

  2. moved this to Waiting for: Support in GitHub Issues with 👀 3on Sep 14, 2026
  3. linear-code commented on Sep 14, 2026

    @linear-code
  4. mhkarimi1383 commented on Sep 14, 2026

    @mhkarimi1383
    Author

    This is the random error that was irrelevant to the problem

    It would be great if it can detect and raise a meaningful error like GitLab

    GitLab also has a upgrade path website that will generate upgrade path between two versions with required notes

    Running migrations for default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    Operations to perform:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
      Apply all migrations: ai_monitoring, auth, contenttypes, explore, feedback, flags, hybridcloud, insights, investigations, nodestore, notifications, releases, seer, sentry, sessions, sites, social_auth, workflow_engine                                                                                                                                                                                                                                                                                                                                                                                                                                 
    Traceback (most recent call last):                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
      File "/.venv/bin/sentry", line 4, in <module>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
        raise SystemExit(main())                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                         ~~~~^^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      File "/usr/src/sentry/src/sentry/runner/main.py", line 146, in main                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
        func(**kwargs)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
        ~~~~^^^^^^^^^^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
      File "/.venv/lib/python3.13/site-packages/click/core.py", line 1442, in __call__                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
        return self.main(*args, **kwargs)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
               ~~~~~~~~~^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
      File "/.venv/lib/python3.13/site-packages/click/core.py", line 1363, in main                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
        rv = self.invoke(ctx)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
      File "/.venv/lib/python3.13/site-packages/click/core.py", line 1830, in invoke                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
        return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^File "/.venv/lib/python3.13/site-packages/click/core.py", line 1226, in invoke                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [0/1932]
        return ctx.invoke(self.callback, **ctx.params)                                                                                                             
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                             
      File "/.venv/lib/python3.13/site-packages/click/core.py", line 794, in invoke                                                                                
        return callback(*args, **kwargs)                                                                                                                           
      File "/.venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func                                                                         
        return f(get_current_context(), *args, **kwargs)                                                                                                           
      File "/usr/src/sentry/src/sentry/runner/decorators.py", line 34, in inner                                                                                    
        return ctx.invoke(f, *args, **kwargs)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^                                                                                                                      
      File "/.venv/lib/python3.13/site-packages/click/core.py", line 794, in invoke 
        return callback(*args, **kwargs)                                                                                                                           
      File "/usr/src/sentry/src/sentry/runner/commands/upgrade.py", line 168, in upgrade
        _upgrade(                                             
        ~~~~~~~~^                                                                                                                                                  
            not noinput,                              
            ^^^^^^^^^^^^                                                                           
        ...<5 lines>...                                                                            
            create_kafka_topics,                                                                   
            ^^^^^^^^^^^^^^^^^^^^                                                                   
        )                                                                                          
        ^                                                                                                                                                                                         
      File "/usr/src/sentry/src/sentry/runner/commands/upgrade.py", line 83, in _upgrade                                                                           
        dj_call_command(                                                                                                                                           
        ~~~~~~~~~~~~~~~^                                                                                                                                           
            "migrate",                                                                                                                                             
            ^^^^^^^^^^                                                                                                                                             
        ...<3 lines>...                                                                                                                                            
            verbosity=verbosity,                                                                                                                                   
            ^^^^^^^^^^^^^^^^^^^^                                                                                                                                   
        )                                                                                                                                                          
        ^                                                                                                                                                          
      File "/.venv/lib/python3.13/site-packages/django/core/management/__init__.py", line 194, in call_command
        return command.execute(*args, **defaults)                                                                                                                  
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^                                                                                                                  
      File "/.venv/lib/python3.13/site-packages/django/core/management/base.py", line 464, in execute
        output = self.handle(*args, **options)                                                                                                                     
      File "/.venv/lib/python3.13/site-packages/django/core/management/base.py", line 111, in wrapper
        res = handle_func(*args, **kwargs)                                                                                                                         
      File "/.venv/lib/python3.13/site-packages/django/core/management/commands/migrate.py", line 299, in handle
        pre_migrate_apps = pre_migrate_state.apps                                                                                                                  
                           ^^^^^^^^^^^^^^^^^^^^^^                                                                                                                  
      File "/.venv/lib/python3.13/site-packages/django/utils/functional.py", line 47, in __get__
        res = instance.__dict__[self.name] = self.func(instance)                                                                                                   
                                             ~~~~~~~~~^^^^^^^^^^                                                                                                   
      File "/.venv/lib/python3.13/site-packages/django/db/migrations/state.py", line 589, in apps
        return StateApps(self.real_apps, self.models)                                                                                                              
      File "/.venv/lib/python3.13/site-packages/django/db/migrations/state.py", line 660, in __init__
        raise ValueError("\n".join(error.msg for error in errors))                                                                                                 
    ValueError: The field feedback.Feedback.environment was declared with a lazy reference to 'sentry.environment', but app 'sentry' isn't installed.
    The field flags.FlagWebHookSigningSecretModel.organization was declared with a lazy reference to 'sentry.organization', but app 'sentry' isn't installed.
    The field insights.InsightsStarredSegment.organization was declared with a lazy reference to 'sentry.organization', but app 'sentry' isn't installed.
    The field insights.InsightsStarredSegment.project was declared with a lazy reference to 'sentry.project', but app 'sentry' isn't installed.
    The field social_auth.UserSocialAuth.user was declared with a lazy reference to 'sentry.user', but app 'sentry' isn't installed.
    
  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 15, 2026
  6. mhkarimi1383 commented on Sep 15, 2026

    @mhkarimi1383
    Author

    I have created this issue on Sentry project iteself initially since it was a migration related thing that happens in the main sentry project

  7. jamgregory commented on Sep 21, 2026

    @jamgregory

    I've experiencing a similar issue when I missed that 26.7.0 was a hard stop 🫣

    For anyone else experiencing this problem, roll your installation back to 26.7.0 and then update your docker-compose.yml file to use Valkey (otherwise Redis will fail to start and you can't run the migrations):

    - image: "redis:6.2.20-alpine"
    + image: "valkey/valkey:8.1.9-alpine"
    
    - test: redis-cli ping | grep PONG
    + test: valkey-cli ping | grep PONG
    
    - command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
    + command: ["valkey-server", "/usr/local/etc/redis/redis.conf"]
    

    I agree with the sentiment though that Sentry should enforce the hard stops and not allow you to upgrade to a newer version if you haven't upgraded to the hard stop release.

  8. mhkarimi1383 commented on Sep 21, 2026

    @mhkarimi1383
    Author

    @jamgregory

    For me it was

    1. docker compose down
    2. Edit .env and change image tag to the older version (hard stop)
    3. docker compose up -d web
    4. docker compose exec -it web sentry upgrade
    5. docker compose down
    6. Change image back in .env
    7. ./install.sh
    8. docker compose up -d --wait

    Using these steps you can migrate database easier

  9. aldy505 commented on Sep 24, 2026

    @aldy505
    Collaborator

    Oh right, we are trying to mitigate this better with this PR: #4489

  10. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 24, 2026
  11. moved this to Waiting for: Community in GitHub Issues with 👀 3on Sep 24, 2026
  12. linked a pull request that will close this issuefeat: install script to check for hard stops #4489on Sep 24, 2026
  13. romanstingler commented on Sep 25, 2026

    @romanstingler

    you can see there is no pride in this project to make it as seemless as possible.
    all the broken migrations back in 25.x there is no script or new version that fixes that CORRECTLY OR FULLY.
    just a "i dont care throwaway project"

  14. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions