Skip to content

'PG::UndefinedTable: ERROR: relation "integrations" does not exist' errors during zero-downtime upgrade from 14.0 to 14.1

Summary

Users will receive 500 errors after the package has been upgraded but before all migrations have been completed during zero-downtime upgrades from 14.0 to 14.1.

Renaming the services table to integrations is one cause, but customers have also seen errors when attempting to access the merge_request_diff_commit_users and dast_site_profiles_builds tables which were added in 14.1 as well.

Steps to reproduce

  1. Establish a GitLab instance on 14.0.9 with two nodes
  2. Add a Jira integration to a project
  3. Perform zero-downtime upgrade with following:
  4. Create /etc/gitlab/skip-auto-reconfigure on deploy node
  5. Install GitLab 14.1.5 package on deploy node
  6. Run SKIP_POST_DEPLOYMENT_MIGRATIONS=true gitlab-ctl reconfigure on deploy node
  7. Run gitlab-ctl hup puma && gitlab-ctl restart sidekiq on deploy node
  8. On other node, the follower, install GitLab 14.1.5 package
  9. Execute gitlab-ctl reconfigure on follower
  10. Run gitlab-ctl hup puma && gitlab-ctl restart sidekiq on follower
  11. Access GitLab, a 500 error is received immediately

Running gitlab-rake db:migrate on deploy node will resolve errors, but downtime cannot be avoided.

What is the current bug behavior?

Users receive errors if accessing GitLab instance during zero-downtime upgrade

What is the expected correct behavior?

No downtime during zero-downtime upgrade.

Relevant logs and/or screenshots

production.log

{                                                                      
  "method": "GET",                                                     
  "path": "/",                                                         
  "format": "html",                                                    
  "controller": "RootController",                                                                                                             
  "action": "index",                                                   
  "status": 500,                                                       
  "time": "2021-09-20T16:55:48.241Z",                                                                                                         
  "params": [],                                                                                            
  "user_id": 1,
  "meta.user": "root",
  "meta.caller_id": "RootController#index",
  "meta.feature_category": "projects",
  "meta.client_id": "user/1",
  "redis_calls": 32,
  "redis_duration_s": 0.034345,
  "redis_read_bytes": 4868,
  "redis_write_bytes": 134721,
  "redis_cache_calls": 31,
  "redis_cache_duration_s": 0.031508,
  "redis_cache_read_bytes": 4687,
  "redis_cache_write_bytes": 133979,
  "redis_shared_state_calls": 1,
  "redis_shared_state_duration_s": 0.002837,
  "redis_shared_state_read_bytes": 181,
  "redis_shared_state_write_bytes": 742,
  "db_count": 26,
  "db_write_count": 0,
  "db_cached_count": 3,
  "cpu_s": 1.091274,
  "mem_objects": 693155,
  "mem_bytes": 79317027,
  "mem_mallocs": 307862,
  "mem_total_bytes": 107043227,
  "queue_duration_s": 0.054985,
  "exception.class": "ActionView::Template::Error",
  "exception.message": "PG::UndefinedTable: ERROR:  relation \"integrations\" does not exist\nLINE 8:  WHERE a.attrelid = '\"integrations\"'::regclass\n                            ^\n",
  "exception.backtrace": [
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:25:in `columns'",
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:29:in `columns_hash'",
    "app/models/integration.rb:84:in `block in <class:Integration>'",
    "app/helpers/user_callouts_helper.rb:41:in `show_service_templates_deprecated_callout?'",
    "app/views/layouts/header/_service_templates_deprecation_callout.html.haml:1",
    "app/views/layouts/_page.html.haml:14",
    "app/views/layouts/application.html.haml:14",
    "app/views/layouts/dashboard.html.haml:6",
    "app/controllers/application_controller.rb:124:in `render'",
    "app/controllers/dashboard/projects_controller.rb:63:in `block in render_projects'",
    "lib/gitlab/gitaly_client.rb:325:in `allow_n_plus_1_calls'",    "app/controllers/dashboard/projects_controller.rb:62:in `render_projects'",
    "app/controllers/dashboard/projects_controller.rb:22:in `block (2 levels) in index'",
    "app/controllers/dashboard/projects_controller.rb:20:in `index'",
    "app/controllers/root_controller.rb:25:in `block in index'",
    "lib/gitlab/gitaly_client.rb:325:in `allow_n_plus_1_calls'",
    "app/controllers/root_controller.rb:23:in `index'",
    "ee/lib/gitlab/ip_address_state.rb:10:in `with'",
    "ee/app/controllers/ee/application_controller.rb:44:in `set_current_ip_address'",
    "app/controllers/application_controller.rb:483:in `set_current_admin'",
    "lib/gitlab/session.rb:11:in `with_session'",
    "app/controllers/application_controller.rb:474:in `set_session_storage'",
    "lib/gitlab/i18n.rb:99:in `with_locale'",
    "lib/gitlab/i18n.rb:105:in `with_user_locale'",
    "app/controllers/application_controller.rb:468:in `set_locale'",
    "app/controllers/application_controller.rb:462:in `set_current_context'",
    "lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'",
    "lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'",
    "lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'",
    "lib/gitlab/metrics/web_transaction.rb:21:in `run'",
    "lib/gitlab/metrics/rack_middleware.rb:16:in `call'",
    "lib/gitlab/middleware/speedscope.rb:13:in `call'",
    "lib/gitlab/request_profiler/middleware.rb:17:in `call'",
    "lib/gitlab/jira/middleware.rb:19:in `call'",
    "lib/gitlab/middleware/go.rb:20:in `call'",
    "lib/gitlab/etag_caching/middleware.rb:21:in `call'",
    "lib/gitlab/middleware/multipart.rb:172:in `call'",
    "lib/gitlab/middleware/read_only/controller.rb:50:in `call'",
    "lib/gitlab/middleware/read_only.rb:18:in `call'",
    "lib/gitlab/middleware/same_site_cookies.rb:27:in `call'",
    "lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'",
    "lib/gitlab/middleware/basic_health_check.rb:25:in `call'",
    "lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'",
    "lib/gitlab/middleware/request_context.rb:21:in `call'",
    "config/initializers/fix_local_cache_middleware.rb:11:in `call'",
    "lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'",
    "lib/gitlab/metrics/requests_rack_middleware.rb:74:in `call'",
    "lib/gitlab/middleware/release_env.rb:12:in `call'"
  ],
  "db_duration_s": 0.19125,
  "view_duration_s": 0,
  "duration_s": 1.25921
}

exceptions_json.log

{
  "severity": "ERROR",
  "time": "2021-09-14T01:39:22.451Z",
  "correlation_id": "01FFGZATHZ0ZNQMPJXG06N40K9",
  "exception.class": "ActiveRecord::StatementInvalid",
  "exception.message": "PG::UndefinedTable: ERROR:  relation \"dast_site_profiles_builds\" does not exist\nLINE 8:  WHERE a.attrelid = '\"dast_site_profiles_builds\"'::regclass\n                            ^\n",
  "exception.backtrace": [
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:25:in `columns'",
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:29:in `columns_hash'",
    "app/services/ci/retry_build_service.rb:67:in `public_send'",
    "app/services/ci/retry_build_service.rb:67:in `block in build_attributes'",
    "app/services/ci/retry_build_service.rb:66:in `to_h'",
    "app/services/ci/retry_build_service.rb:66:in `build_attributes'",
    "app/services/ci/retry_build_service.rb:60:in `clone_build'",
    "app/services/ci/retry_build_service.rb:37:in `reprocess!'",
    "app/services/ci/retry_build_service.rb:20:in `execute'",
    "app/models/ci/build.rb:222:in `retry'",
    "app/models/ci/build.rb:363:in `block (2 levels) in <class:Build>'",
{
  "severity": "ERROR",
  "time": "2021-09-14T01:39:13.500Z",
  "correlation_id": "01FFGZAHVV22GGK2ZH01TK7QA8",
  "exception.class": "ActiveRecord::StatementInvalid",
  "exception.message": "PG::UndefinedTable: ERROR:  relation \"merge_request_diff_commit_users\" does not exist\nLINE 8:  WHERE a.attrelid = '\"merge_request_diff_commit_users\"'::reg...\n                            ^\n",
  "exception.backtrace": [
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:25:in `columns'",
    "lib/gitlab/database/schema_cache_with_renamed_table.rb:29:in `columns_hash'",
    "app/models/merge_request_diff.rb:705:in `map'",
    "app/models/merge_request_diff.rb:705:in `load_commits'",
    "lib/gitlab/metrics/instrumentation.rb:160:in `block in load_commits'",
    "lib/gitlab/metrics/method_call.rb:27:in `measure'",
    "lib/gitlab/metrics/instrumentation.rb:160:in `load_commits'",
    "app/models/merge_request_diff.rb:293:in `block in commits'",
    "lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'",
    "app/models/merge_request_diff.rb:292:in `commits'",
    "lib/gitlab/metrics/instrumentation.rb:160:in `block in commits'",
    "lib/gitlab/metrics/method_call.rb:27:in `measure'",
    "lib/gitlab/metrics/instrumentation.rb:160:in `commits'",
    "app/models/merge_request.rb:615:in `commits'",
    "lib/gitlab/metrics/instrumentation.rb:160:in `block in commits'",

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:         Ubuntu 20.04
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.7.2p137
Gem Version:    3.1.4
Bundler Version:2.1.4
Rake Version:   13.0.3
Redis Version:  6.0.14
Git Version:    2.32.0
Sidekiq Version:5.2.9
Go Version:     unknown

GitLab information
Version:        14.1.5-ee
Revision:       a530ac19fe4
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     12.7
Elasticsearch:  no
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers: 

GitLab Shell
Version:        13.19.1
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.19.1 ? ... OK (13.19.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 1/2 ... yes Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.31.0 ? ... yes (2.32.0) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Edited by Will Chandler (ex-GitLab)