#!/bin/bash set -eu # shellcheck source=/dev/null source "${BASE}/env_${ENVIRONMENT}" azure_master_lsn="$(echo "select case when pg_is_in_recovery() then pg_last_xlog_replay_location() else pg_current_xlog_location() end;" \ | ssh_remote "$AZURE_MASTER" sudo -u gitlab-psql gitlab-psql -v ON_ERROR_STOP=1 -d postgres -t -A)" gcp_master_candidate_lsn="$(echo "select case when pg_is_in_recovery() then pg_last_xlog_replay_location() else pg_current_xlog_location() end;" \ | ssh_remote "$GCP_MASTER_CANDIDATE" sudo -u gitlab-psql gitlab-psql -v ON_ERROR_STOP=1 -d postgres -t -A)" if [ "$azure_master_lsn" == "$gcp_master_candidate_lsn" ] then echo "GCP and Azure have same LSN: $azure_master_lsn" exit 0 fi echo "GCP and Azure have NOT same LSN. Current LSNs are: Azure/$azure_master_lsn GCP/$gcp_master_candidate_lsn" exit 1