Database "gitlabhq_production" is being accessed by other users

Hello everyone !

i am trying to totally reset my gitlab using gitlab-rake gitlab:setup DISABLE_DATABASE_ENVIRONMENT _CHECK=1, but i keep having the issue of the title. The full error message is

[root@mirage gitlab]# gitlab-rake gitlab:setup DISABLE_DATABASE_ENVIRONMENT_CHECK=1
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? yes

PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
DETAIL:  There is 1 other session using the database.
Couldn't drop database 'gitlabhq_production'
rake aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
DETAIL:  There is 1 other session using the database.
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:35:in `setup_db'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:7:in `block (2 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'

Caused by:
PG::ObjectInUse: ERROR:  database "gitlabhq_production" is being accessed by other users
DETAIL:  There is 2 other session using the database.
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:35:in `setup_db'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/setup.rake:7:in `block (2 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

I stopped puma, unicorn, gitlab-monitor and sidekiq, but i still have a connection to the database.

when i try ps aux | grep postgres*, i have the following :

gitlab-+  3154  0.0  0.0 1058928 2360 ?        Ss   10:03   0:00 postgres: checkpointer
gitlab-+  3155  0.0  0.2 1058796 10012 ?       Ss   10:03   0:00 postgres: background writer
gitlab-+  3156  0.0  0.0 1058796 2372 ?        Ss   10:03   0:00 postgres: walwriter
gitlab-+  3157  0.0  0.0 1059520 3520 ?        Ss   10:03   0:00 postgres: autovacuum launcher
gitlab-+  3158  0.0  0.0  32248  2524 ?        Ss   10:03   0:00 postgres: stats collector
gitlab-+  3159  0.0  0.0 1059388 3104 ?        Ss   10:03   0:00 postgres: logical replication launcher
gitlab-+  3165  0.7  0.5 1168776 21716 ?       Ss   10:03   0:06 postgres: gitlab gitlabhq_production [local] idle
gitlab-+  3187  0.3  1.0 1187948 41544 ?       Ss   10:04   0:02 postgres: gitlab-psql gitlabhq_production [local] idle
root      3444  0.0  0.0 112836   984 pts/1    S+   10:18   0:00 grep --color=auto postgre*
root     11709  0.0  0.0   4228    96 ?        Ss   avril28   0:01 runsv postgresql
root     11718  0.0  0.0   4228    40 ?        Ss   avril28   0:01 runsv postgres-exporter
root     11732  0.0  0.0   4372    80 ?        S    avril28   0:01 svlogd -tt /var/log/gitlab/postgresql
root     11740  0.0  0.0   4372   124 ?        S    avril28   0:01 svlogd -tt /var/log/gitlab/postgres-exporter
gitlab-+ 26327  0.1  0.3 839816 11928 ?        Ssl  09:05   0:08 /opt/gitlab/embedded/bin/postgres_exporter --web.listen-address=localhost:9187 --extend.query-path=/var/opt/gitlab/postgres-exporter/queries.yaml
gitlab-+ 26335  0.0  1.3 1058796 50856 ?       Ss   09:05   0:00 /opt/gitlab/embedded/bin/postgres -D /var/opt/gitlab/postgresql/data

and even if i kill processes linked to gitlabhq_production, they keep coming back.

my gitlab is up to date, (so Kill all PostgreSQL connections for rake dev:setup (!24743) · Merge requests · GitLab.org / GitLab FOSS · GitLab is closed and merged i guess) and i found this Error when running sudo gitlab-rake gitlab:setup (#56993) · Issues · GitLab.org / GitLab FOSS · GitLab which did not really help much unfortunately.

Do you have any idea of what to do to prevent that, and perform the full reset of the gitlab ?

Have a great day