When: Tue 23rd 06:00 AM UTC
NEW primary: es1021
OLD primary: es1020
[x] Check configuration differences between new and old primary:
```
sudo pt-config-diff --defaults-file /root/.my.cnf h=es1020.eqiad.wmnet h=es1021.eqiad.wmnet
```
**Failover prep:**
[x] Disable writes to es4 by merging this patch: https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/825234/
[] Check there are no writes
[] Silence alerts on all hosts:
```
sudo cookbook sre.hosts.downtime --hours 2 -r "Switchover es4 T315540" 'A:db-section-es4'
```
[] Set NEW primary with weight 10
```
sudo dbctl instance es1021 set-weight 10
sudo dbctl config commit -m "Set es1021 with weight 10 T315540"
```
[] Topology changes, move all replicas under NEW primary
```
sudo db-switchover --timeout=15 --only-slave-move es1020 es1021
```
[] Disable puppet on both nodes
```
sudo cumin 'es1020* or es1021*' 'disable-puppet "primary switchover T315540"'
```
[] Merge gerrit puppet change to promote NEW primary: https://gerrit.wikimedia.org/r/c/operations/puppet/+/825245
**Failover:**
[] Log the failover:
```
!log Starting es4 eqiad failover from es1020 to es1021 - T315540
```
[] Switch primaries:
```
sudo db-switchover --skip-slave-move es1020 es1021
echo "===== es1020 (OLD)"; sudo db-mysql es1020 -e 'show slave status\G'
echo "===== es1021 (NEW)"; sudo db-mysql es1021 -e 'show slave status\G'
```
[] Promote NEW primary in dbctl, and remove read-only
```
sudo dbctl --scope eqiad section es4 set-master es1021
sudo dbctl config commit -m "Promote es1021 to es4 primary T315540"
```
[] Restart puppet on both hosts:
```
sudo cumin 'es1020* or es1021*' 'run-puppet-agent -e "primary switchover T315540"'
```
**Clean up tasks:**
[] Clean up heartbeat table(s).
[] change events for query killer:
```
events_coredb_master.sql on the new primary es1021
events_coredb_slave.sql on the new slave es1020
```
[] Update DNS: https://gerrit.wikimedia.org/r/c/operations/dns/+/825247/
[] Re-enable writes on es4: https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/825266
[] Update candidate primary dbctl notes and orchestrator
```
sudo dbctl instance es1020 set-candidate-master --section es4 true
sudo dbctl instance es1021 set-candidate-master --section es4 false
(dborch1001): sudo orchestrator-client -c untag -i es1021 --tag name=candidate
(dborch1001): sudo orchestrator-client -c tag -i es1020 --tag name=candidate
```
[] Check zarcillo was updated
** db-switchover should do this. If it fails, do it manually: https://phabricator.wikimedia.org/P13956
[] Depool OLD primary for reboot
```
sudo dbctl instance es1020 depool
sudo dbctl config commit -m "Depool es1020 for reboot T310485"
```