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