052-check-azure-nodes-has-same-gcp-lsn.sh 869 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/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