When: During a pre-defined DBA maintenance windows
Affected wikis:: TO-DO
Checklist:
NEW primary: db2162
OLD primary: db2241
- Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=db2241.codfw.wmnet h=db2162.codfw.wmnet
Failover prep:
- Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover x3 T399456" 'A:db-section-x3'
- Set NEW primary with weight 0
sudo dbctl instance db2162 set-weight 0 sudo dbctl config commit -m "Set db2162 with weight 0 T399456"
- Depool NEW from any specific group (API, vslow, dump) if present.
sudo dbctl instance db2162 edit # If some changes were made: sudo dbctl config commit -m "Remove db2162 from API/vslow/dump T399456"
- Topology changes, move all replicas under NEW primary
sudo db-switchover --timeout=25 --replicating-master --read-only-master --only-slave-move db2241 db2162
- Disable puppet on both nodes
sudo cumin 'db2241* or db2162*' 'disable-puppet "primary switchover T399456"'
- Merge gerrit puppet change to promote NEW primary: https://gerrit.wikimedia.org/r/c/operations/puppet/+/1169093/
Failover:
- Log the failover:
!log Starting x3 codfw failover from db2241 to db2162 - T399456
- Switch primaries:
sudo db-switchover --replicating-master --read-only-master --skip-slave-move db2241 db2162 echo "===== db2241 (OLD)"; sudo db-mysql db2241 -e 'show slave status\G' echo "===== db2162 (NEW)"; sudo db-mysql db2162 -e 'show slave status\G'
- Promote NEW primary in dbctl
sudo dbctl --scope codfw section x3 set-master db2162 sudo dbctl config commit -m "Promote db2162 to x3 primary T399456"
- Clean up heartbeat table(s).
sudo db-mysql db2162 heartbeat -e "delete from heartbeat where file like 'db2241%';"
- Restart puppet on both hosts:
sudo cumin 'db2241* or db2162*' 'run-puppet-agent -e "primary switchover T399456"'
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 db2162 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 db2241
- Update candidate primary dbctl and orchestrator notes
sudo dbctl instance db2241 set-candidate-master --section x3 true sudo dbctl instance db2162 set-candidate-master --section x3 false sudo cumin 'dborch*' 'orchestrator-client -c untag -i db2162 --tag name=candidate' sudo cumin 'dborch*' 'orchestrator-client -c tag -i db2241 --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 = 'x3';"
- (If needed): Depool db2241 for maintenance.
sudo dbctl instance db2241 depool sudo dbctl config commit -m "Depool db2241 T399456"
- Change db2241 weight to mimic the previous weight db2162 (main/api/vslow/dumps):
sudo dbctl instance db2241 edit
- Update/resolve this ticket.