Part of {T300006}
**When:** FIXME
**Checklist:**
[x] Create a task to communicate the chosen date and send an announcement to the community: FIXME
[x] Create a calendar entry for the maintenance, invite sre-data-persistence@
[x] Add to deployments calendar. E.g.:
```
{{Deployment calendar event card
|when=2021-08-24 23:00 SF
|length=0.5
|window=Database primary switchover for s7
|who={{ircnick|kormat|Stevie Beth Mhaol}}, {{ircnick|marostegui|Manuel 'Early Bird' Arostegui}}, {{ircnick|Amir1|Amir}}
|what=https://phabricator.wikimedia.org/T300006
}}
```
NEW primary: es1023
OLD primary: es1024
[x] Check configuration differences between new and old primary:
```
sudo pt-config-diff --defaults-file /root/.my.cnf h=es1024.eqiad.wmnet h=es1023.eqiad.wmnet
```
**Failover prep:**
[x] Silence alerts on all hosts:
```
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover es5 T300006" 'A:db-section-es5'
```
[x] Set NEW primary with weight 0
```
sudo dbctl instance es1023 set-weight 0
sudo dbctl config commit -m "Set es1023 with weight 0 T300006"
```
[x] Topology changes, move all replicas under NEW primary
```
sudo db-switchover --timeout=15 --only-slave-move es1024 es1023
```
[x] Disable puppet on both nodes
```
sudo cumin 'es1024* or es1023*' 'disable-puppet "primary switchover T300006"'
```
[x] Merge gerrit puppet change to promote NEW primary: FIXME
**Failover:**
[x] Log the failover:
```
!log Starting es5 eqiad failover from es1024 to es1023 - T300006
```
[x] Set section read-only:
```
sudo dbctl --scope eqiad section es5 ro "Maintenance until 05:15 UTC - T300006"
sudo dbctl config commit -m "Set es5 eqiad as read-only for maintenance - T300006"
```
[x] Check es5 is indeed read-only
[x] Switch primaries:
```
sudo db-switchover --skip-slave-move es1024 es1023
echo "===== es1024 (OLD)"; sudo db-mysql es1024 -e 'show slave status\G'
echo "===== es1023 (NEW)"; sudo db-mysql es1023 -e 'show slave status\G'
```
[x] Promote NEW primary in dbctl, and remove read-only
```
sudo dbctl --scope eqiad section es5 set-master es1023
sudo dbctl --scope eqiad section es5 rw
sudo dbctl config commit -m "Promote es1023 to es5 primary and set section read-write T300006"
```
[x] Restart puppet on both hosts:
```
sudo cumin 'es1024* or es1023*' 'run-puppet-agent -e "primary switchover T300006"'
```
**Clean up tasks:**
[x] Clean up heartbeat table(s).
[x] change events for query killer:
```
events_coredb_master.sql on the new primary es1023
events_coredb_slave.sql on the new slave es1024
```
[] Update DNS: FIXME
[] Update candidate primary dbctl notes
```
sudo dbctl instance es1024 set-candidate-master --section es5 true
sudo dbctl instance es1023 set-candidate-master --section es5 false
```
[] Check zarcillo was updated
** db-switchover should do this. If it fails, do it manually: https://phabricator.wikimedia.org/P13956
[] (If needed): Depool es1024 for maintenance.
```
sudo dbctl instance es1024 depool
sudo dbctl config commit -m "Depool es1024 T300006"
```
[] Apply outstanding schema changes to es1024 (if any)
[] Update/resolve this ticket.