When: During a pre-defined DBA maintenance windows
Prerequisites: https://wikitech.wikimedia.org/wiki/MariaDB/Primary_switchover
Affected wikis:: TO-DO
Checklist:
NEW primary: db1261
OLD primary: db1263
- Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=db1263.eqiad.wmnet h=db1261.eqiad.wmnet
Failover prep:
- Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover x4 T437695" 'A:db-section-x4'
- Set NEW primary with weight 0
sudo dbctl instance db1261 set-weight 0 sudo dbctl config commit -m "Set db1261 with weight 0 T437695"
- Topology changes, move all replicas under NEW primary, open orchestartor to monitor the process and check it at the end.
sudo db-switchover --timeout=25 --only-slave-move db1263 db1261
- Disable puppet on both nodes
sudo cumin 'db1263* or db1261*' 'disable-puppet "primary switchover T437695"'
- Merge gerrit puppet change to promote NEW primary: FIXME
ssh puppetserver1001.eqiad.wmnet sudo puppet-merge
Failover:
- Log the failover:
!log Starting x4 eqiad failover from db1263 to db1261 - T437695
- Set section read-only:
sudo dbctl --scope eqiad section x4 ro "Maintenance until 06:15 UTC - T437695" sudo dbctl --scope codfw section x4 ro "Maintenance until 06:15 UTC - T437695" sudo dbctl config commit -m "Set x4 eqiad as read-only for maintenance - T437695"
- Check x4 is indeed read-only
- Switch primaries:
sudo db-switchover --skip-slave-move db1263 db1261 echo "===== db1263 (OLD)"; sudo db-mysql db1263 -e 'show slave status\G' echo "===== db1261 (NEW)"; sudo db-mysql db1261 -e 'show slave status\G'
- Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope eqiad section x4 set-master db1261 sudo dbctl --scope eqiad section x4 rw sudo dbctl --scope codfw section x4 rw sudo dbctl config commit -m "Promote db1261 to x4 primary and set section read-write T437695"
- Clean up heartbeat table(s).
sudo db-mysql db1261 heartbeat -e "delete from heartbeat where file like 'db1263%';"
- Restart puppet on both hosts:
sudo cumin 'db1263* or db1261*' 'run-puppet-agent -e "primary switchover T437695"'
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 db1261 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 db1263
- Merge DNS change (ssh ns0.wikimedia.org): FIXME
sudo authdns-update
- Update candidate primary dbctl and orchestrator notes
sudo dbctl instance db1263 set-candidate-master --section x4 true sudo dbctl instance db1261 set-candidate-master --section x4 false sudo cumin 'dborch*' 'orchestrator-client -c untag -i db1261 --tag name=candidate' sudo cumin 'dborch*' 'orchestrator-client -c tag -i db1263 --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 = 'x4';"
- Depool db1263 for maintenance.
sudo dbctl instance db1263 depool sudo dbctl config commit -m "Depool db1263 T437695"
- Change db1263 weight to mimic the previous weight db1261:
sudo dbctl instance db1263 edit
- Apply outstanding schema changes to db1263 (if any)
- Slowly repool the db1263 if ready
sudo cookbook sre.mysql.pool -t T437695 -r "Repooling after switchover" db1263
- Update/resolve this ticket.