When: Anytime - no in use
Prerequisites: https://wikitech.wikimedia.org/wiki/MariaDB/Primary_switchover
Checklist:
NEW primary: es2035
OLD primary: es2037
- Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=es2037.codfw.wmnet h=es2035.codfw.wmnet
Failover prep:
- Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover es6 T400436" 'A:db-section-es6'
- Set NEW primary with weight 0 (and depool it from API or vslow/dump groups if it is present).
sudo dbctl instance es2035 set-weight 0 sudo dbctl config commit -m "Set es2035 with weight 0 T400436"
- Topology changes, move all replicas under NEW primary
sudo db-switchover --read-only-master --replicating-master --timeout=25 --only-slave-move es2037 es2035
- Disable puppet on both nodes
sudo cumin 'es2037* or es2035*' 'disable-puppet "primary switchover T400436"'
- Merge gerrit puppet change to promote NEW primary: https://gerrit.wikimedia.org/r/c/operations/puppet/+/1172512
Failover:
- Log the failover:
!log Starting es6 codfw failover from es2037 to es2035 - T400436
- Switch primaries:
sudo db-switchover --read-only-master --replicating-master --skip-slave-move es2037 es2035 echo "===== es2037 (OLD)"; sudo db-mysql es2037 -e 'show slave status\G' echo "===== es2035 (NEW)"; sudo db-mysql es2035 -e 'show slave status\G'
- Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope codfw section es6 set-master es2035 sudo dbctl config commit -m "Promote es2035 to es6 primary T400436"
- Clean up heartbeat table(s).
sudo db-mysql es2035 heartbeat -e "delete from heartbeat where file like 'es2037%';"
- Restart puppet on both hosts:
sudo cumin 'es2037* or es2035*' 'run-puppet-agent -e "primary switchover T400436"'
Clean up tasks:
- change events for query killer:
curl -sS 'https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/+/refs/heads/master/dbtools/events_coredb_master.sql?format=TEXT' | base64 -d | sudo db-mysql es2035 curl -sS 'https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/+/refs/heads/master/dbtools/events_coredb_slave.sql?format=TEXT' | base64 -d | sudo db-mysql es2037
- Update candidate primary dbctl and orchestrator notes
sudo dbctl instance es2037 set-candidate-master --section es6 true sudo dbctl instance es2035 set-candidate-master --section es6 false sudo cumin 'dborch*' 'orchestrator-client -c untag -i es2035 --tag name=candidate' sudo cumin 'dborch*' 'orchestrator-client -c tag -i es2037 --tag name=candidate'
- Check zarcillo was updated
- db-switchover should do this. If it fails, do it manually: https://phabricator.wikimedia.org/P13956
sudo db-mysql db1215 zarcillo -e "select * from masters where section = 'es6';"
- (If needed): Depool es2037 for maintenance.
sudo dbctl instance es2037 depool sudo dbctl config commit -m "Depool es2037 T400436"
- Change es2037 weight to mimic the previous weight es2035:
sudo dbctl instance es2037 edit
- Update/resolve this ticket.