PostgreSQL Won't Load after downgrading from EE to CE

Hello, I just downgraded us from (omnibus) Gitlab EE to CE. However, I believe version may not have been quite the same and now PostgreSQL will not start.

I have done the following:

sudo gitlab-ctl reconfigure

only to result in the following error:

`Recipe: gitlab::postgresql-bin

  • ruby_block[Link postgresql bin files to the correct version] action run

    • execute the ruby block Link postgresql bin files to the correct version
      Recipe: gitlab::postgresql
  • template[/opt/gitlab/etc/gitlab-psql-rc] action create (up to date)

  • postgresql_user[gitlab] action create

    • execute[create gitlab postgresql user] action run (skipped due to not_if)
    • execute[set password for gitlab postgresql user] action run (skipped due to not_if)
      (up to date)
  • execute[create gitlabhq_production database] action run (skipped due to not_if)

  • postgresql_user[gitlab_replicator] action create

    • execute[create gitlab_replicator postgresql user] action run (skipped due to not_if)
    • execute[set password for gitlab_replicator postgresql user] action run (skipped due to not_if)
      (up to date)
  • execute[enable pg_trgm extension] action run (skipped due to not_if)

  • execute[reload postgresql] action nothing (skipped due to action :nothing)

  • execute[start postgresql] action nothing (skipped due to action :nothing)
    Recipe: gitlab::database_migrations

  • bash[migrate gitlab-rails database] action run
    [execute] rake aborted!
    PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket “/var/opt/gitlab/postgresql/.s.PGSQL.5432”?
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:49:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
    /opt/gitlab/embedded/bin/bundle:23:in `’
    Tasks: TOP => gitlab:db:configure
    (See full trace by running task with --trace)

    Error executing action run on resource ‘bash[migrate gitlab-rails database]’
    Mixlib::ShellOut::ShellCommandFailed

    Expected process to exit with [0], but received ‘1’
    ---- Begin output of “bash” “/tmp/chef-script20171209-57533-ygemg9” ----
    STDOUT: rake aborted!
    PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket “/var/opt/gitlab/postgresql/.s.PGSQL.5432”?
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:49:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
    /opt/gitlab/embedded/bin/bundle:23:in <main>' Tasks: TOP => gitlab:db:configure (See full trace by running task with --trace) STDERR: ---- End output of "bash" "/tmp/chef-script20171209-57533-ygemg9" ---- Ran "bash" "/tmp/chef-script20171209-57533-ygemg9" returned 1

I also then ran: sudo gitlab-rake gitlab:env:info

System information
System: Ubuntu 14.04
Current User: git
Using RVM: no
Ruby Version: 2.3.5p376
Gem Version: 2.6.13
Bundler Version:1.13.7
Rake Version: 12.1.0
Redis Version: 3.2.5
Git Version: 2.13.6
Sidekiq Version:5.0.4
Go Version: unknown
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/opt/gitlab/postgresql/.s.PGSQL.5432”?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/info.rake:38:in block (3 levels) in <top (required)>' /opt/gitlab/embedded/bin/bundle:23:in load’
/opt/gitlab/embedded/bin/bundle:23:in `’
Tasks: TOP => gitlab:env:info
(See full trace by running task with --trace)

Please help! My team is unable to commit and or make progress while this is down!

Thanks,
Mike

I had this happen to me yesterday. We use Gitlab EE docker image. I caused the problem by upgrading Gitlab to version 13, which ships with Postgres 11. Postgres kept logging this error:

2020-07-05_21:47:11.46248 FATAL:  database files are incompatible with server
2020-07-05_21:47:11.46251 DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.7.

I fixed the problem by downgrading Gitlab to 12.8, which uses Postgres 10 by default. It was a mistake on my part to use the gitlab-ee:latest tag during the upgrade. I have pinned the docker image we use to a specific Gitlab version now.

I am planning to manually upgrade to Postgres 11 using the pg-upgrade script before upgrading to Gitlab 13.