When: Anytime, writes will be disabled
Prerequisites: https://wikitech.wikimedia.org/wiki/MariaDB/Primary_switchover
Checklist:
NEW primary: es2037
OLD primary: es2035
- Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=es2035.codfw.wmnet h=es2037.codfw.wmnet
- Disable writes in es6 by making a patch similar to https://gerrit.wikimedia.org/r/922376 and deploying it: https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/1122533
(in deployment.eqiad.org):
scap backport 1122533
- Check es6 is indeed read-only
Failover prep:
- Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover es6 T387211" '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 es2037 set-weight 0 sudo dbctl config commit -m "Set es2037 with weight 0 T387211"
- Topology changes, move all replicas under NEW primary
sudo db-switchover --timeout=25 --only-slave-move es2035 es2037
- Disable puppet on both nodes
sudo cumin 'es2035* or es2037*' 'disable-puppet "primary switchover T387211"'
- Merge gerrit puppet change to promote NEW primary: https://gerrit.wikimedia.org/r/1122568
Failover:
- Log the failover:
!log Starting es6 codfw failover from es2035 to es2037 - T387211
- Switch primaries:
sudo db-switchover --skip-slave-move es2035 es2037 echo "===== es2035 (OLD)"; sudo db-mysql es2035 -e 'show slave status\G' echo "===== es2037 (NEW)"; sudo db-mysql es2037 -e 'show slave status\G'
- Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope codfw section es6 set-master es2037 sudo dbctl config commit -m "Promote es2037 to es6 primary T387211"
- Clean up heartbeat table(s).
sudo db-mysql es2037 heartbeat -e "delete from heartbeat where file like 'es2035%';"
- Restart puppet on both hosts:
sudo cumin 'es2035* or es2037*' 'run-puppet-agent -e "primary switchover T387211"'
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 es2037 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 es2035
- Update DNS: https://gerrit.wikimedia.org/r/1122569
- Update candidate primary dbctl and orchestrator notes
sudo dbctl instance es2035 set-candidate-master --section es6 true sudo dbctl instance es2037 set-candidate-master --section es6 false sudo cumin 'dborch*' 'orchestrator-client -c untag -i es2037 --tag name=candidate' sudo cumin 'dborch*' 'orchestrator-client -c tag -i es2035 --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 es2035 for maintenance.
sudo dbctl instance es2035 depool sudo dbctl config commit -m "Depool es2035 T387211"
- Change es2035 weight to mimic the previous weight es2037:
sudo dbctl instance es2035 edit
- Enable writes in es6 by merging and deploying revert of mediawiki config patch:
(in deployment.eqiad.org)
scap backport 1122570
- Update/resolve this ticket.