Commit 7c83f328 authored by Nikolay's avatar Nikolay

promote with pg_ctl; exclude own pid from terminating connections

parent 985b041a
Pipeline #88370 passed with stage
in 59 seconds
......@@ -532,21 +532,16 @@ of errors while it is being promoted.
ssh_remote "$host" "sudo -u gitlab-psql cp /var/opt/gitlab/postgresql/data/pg_hba.conf /var/opt/gitlab/postgresql/data/pg_hba.conf.backup"
ssh_remote "$host" "sudo -u gitlab-psql mv /var/opt/gitlab/postgresql/data/pg_hba.conf.tmp /var/opt/gitlab/postgresql/data/pg_hba.conf"
ssh_remote "$host" "cd /tmp; sudo -u gitlab-psql gitlab-psql -c 'select pg_reload_conf()'"
ssh_remote "$host" "cd /tmp; sudo -u gitlab-psql gitlab-psql -c 'select pg_terminate_backend(pid) from pg_stat_activity where datname = 'gitlabhq_production''"
ssh_remote "$host" "cd /tmp; sudo -u gitlab-psql gitlab-psql -c \
\"select pg_terminate_backend(pid) from pg_stat_activity where datname = 'gitlabhq_production' and pid <> pg_backend_pid()\""
done
```
1. [ ] 🐘 {+ Database-Wrangler +}: Perform regular switchover to the main replica on GCP
```shell
# TODO (NikolayS) Prepare trigger_file much earlier or use `pg_ctl promote`
ssh_remote "$GCP_MASTER_CANDIDATE" $(cat << EOF
cd /tmp;
sudo -u gitlab-psql "echo \"trigger_file = '/var/opt/gitlab/postgresql/data/trigger_file'\" > /var/opt/gitlab/postgresql/data/recovery.conf";
sudo -u gitlab-psql gitlab-psql -c 'select pg_reload_conf()'
EOF
)
# WARNING WARNING WARNING here switchover happens!
ssh_remote "$GCP_MASTER_CANDIDATE" "sudo -u gitlab-psql touch /var/opt/gitlab/postgresql/data/trigger_file"
ssh_remote "$GCP_MASTER_CANDIDATE" \
"/opt/gitlab/embedded/bin/pg_ctl -D /var/opt/gitlab/postgresql/data promote"
```
TODO --- more checks --- (below this line DB steps are not reworked // NikolayS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment