From 07d520763e2faf199a9941a18a51e3963e66bdd4 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 3 Apr 2020 00:43:54 +0200 Subject: [PATCH] TT#78950 improve ngcp-update-db 3308 sync * determine the master db node name to use for ngcp-sync-db master-slave replication restoration if the CENTRAL_DBHOST is set by default to db01 only. if the current nodename ends with "a" then db01a is used, otehrwise db01b is used as the master host. that is to make sure that during the upgrade the correct "side" is used to replicate the data from and avoid lossy statements that break replication. Change-Id: I1a51bd0d975390d9269ef5208ce8275f9e055a1f (cherry picked from commit 1cfafba736597d01bda45d0468882b160792ce5e) --- ngcp-update-db-schema | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ngcp-update-db-schema b/ngcp-update-db-schema index 826416a2..d69c6994 100755 --- a/ngcp-update-db-schema +++ b/ngcp-update-db-schema @@ -257,6 +257,20 @@ if $RUN_SYNC_DB && ($NOT_REPLICATED_REV_APPLIED || [ -n "$AUTOMATED_INSTALL_MODE if [ -n "$AUTOMATED_INSTALL_MODE" ] ; then EXTRA_SYNC_DB_OPTS="--local-user=root --set-local-grants" fi + + # determine the preferred db node a or b if the default db01 is the constants + MASTER_NODE_PREF="" + if [ "$CENTRAL_DBHOST" == "db01" ] ; then + NODE_SIDE="a" + if [[ "$nodename" == *b ]] ; then + NODE_SIDE="b" + fi + MASTER_NODE_PREF="db01${NODE_SIDE}" + fi + if [ -n "$MASTER_NODE_PREF" ] ; then + EXTRA_SYNC_DB_OPTS="$EXTRA_SYNC_DB_OPTS --master-host $MASTER_NODE_PREF" + fi + # shellcheck disable=SC2086 if /usr/sbin/ngcp-sync-db --verbose --force --use-central-db --repl-mode "master-slave" --databases "${PRX_SYNC_DBS}" --ignore-tables "${PRX_IGNORE_TABLES}" --ssh-tunnel=33125 ${EXTRA_SYNC_DB_OPTS} --local-host=${LOCAL_DBHOST} --local-port=${LOCAL_DBPORT}; then echo "Syncing 'not_replicated' statements from the central node."