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