Skip to content

Commit

Permalink
Refactor PostgreSQL promotion scripts to use virtual IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezborder committed Jan 2, 2025
1 parent e76d713 commit c94d7e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
9 changes: 2 additions & 7 deletions resources/templates/default/notify_backup_postgresql.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,5 @@ if [ $found -eq 1 ]; then
fi

# Promoting to slave
echo "Promoting to slave $CURRENT_NODE. Sleeping for 30 seconds to update promoting serf tag from master node" >> "$LOG_FILE"
sleep 30
SERF_OUTPUT=$(serf members)
MEMBER_NAME=$(echo "$SERF_OUTPUT" | grep -oP 'promoting=\K[^,]+')

echo "Executing rb_sync_from_master.sh $MEMBER_NAME" >> "$LOG_FILE"
/usr/lib/redborder/bin/rb_sync_from_master.sh $MEMBER_NAME >> "$LOG_FILE"
echo "Promoting to slave $CURRENT_NODE with IP: $VIRTUAL_IP" >> "$LOG_FILE"
/usr/lib/redborder/bin/rb_sync_from_master.sh $VIRTUAL_IP >> "$LOG_FILE"
8 changes: 1 addition & 7 deletions resources/templates/default/notify_master_postgresql.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ fi

# Promoting to master
echo "Promoting to master $CURRENT_NODE" >> "$LOG_FILE"
serf tags -set promoting=$CURRENT_NODE >> "$LOG_FILE"
touch /tmp/postgresql.trigger
sed -i '/^primary_conninfo/d' /var/lib/pgsql/data/postgresql.conf
sed -i '/^promote_trigger_file/d' /var/lib/pgsql/data/postgresql.conf

echo "Sleeping for 3 minutes to remove promoting serf tag" >> "$LOG_FILE"
sleep 180
serf tags -delete promoting >> "$LOG_FILE"
echo "serf tag has been deleted" >> "$LOG_FILE"
sed -i '/^promote_trigger_file/d' /var/lib/pgsql/data/postgresql.conf

0 comments on commit c94d7e4

Please sign in to comment.