**When:** 11th Nov at 06:00 AM UTC
**Checklist:**
[] Create a task to communicate the chosen date and send an announcement to the community: T294322
[] Create a calendar entry for the maintenance, invite sre-data-persistence@
[] 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}}
|what=https://phabricator.wikimedia.org/T294321
}}
```
NEW primary: db1109
OLD primary: db1104
[] Check configuration differences between new and old primary:
```
sudo pt-config-diff --defaults-file /root/.my.cnf h=db1104.eqiad.wmnet h=db1109.eqiad.wmnet
```
**Failover prep:**
[] Silence alerts on all hosts:
```
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover s8 T294321" 'A:db-section-s8'
```
[] Set NEW primary with weight 0
```
sudo dbctl instance db1109 set-weight 0
sudo dbctl config commit -m "Set db1109 with weight 0 T294321"
```
[] Topology changes, move all replicas under NEW primary
```
sudo db-switchover --timeout=15 --only-slave-move db1104 db1109
```
[] Disable puppet on both nodes
```
sudo cumin 'db1104* or db1109*' 'disable-puppet "primary switchover T294321"'
```
[] Merge gerrit puppet change to promote NEW primary: FIXME
**Failover:**
[] Log the failover:
```
!log Starting s8 eqiad failover from db1104 to db1109 - T294321
```
[] Set section read-only:
```
sudo dbctl --scope eqiad section s8 ro "Maintenance until 05:15 UTC - T294321"
sudo dbctl config commit -m "Set s8 eqiad as read-only for maintenance - T294321"
```
[] Check s8 is indeed read-only
[] Switch primaries:
```
sudo db-switchover --skip-slave-move db1104 db1109
echo "===== db1104 (OLD)"; sudo mysql.py -h db1104 -e 'show slave status\G'
echo "===== db1109 (NEW)"; sudo mysql.py -h db1109 -e 'show slave status\G'
```
[] Promote NEW primary in dbctl, and remove read-only
```
sudo dbctl --scope eqiad section s8 set-master db1109
sudo dbctl --scope eqiad section s8 rw
sudo dbctl config commit -m "Promote db1109 to s8 primary and set section read-write T294321"
```
[] Restart puppet on both hosts:
```
sudo cumin 'db1104* or db1109*' 'run-puppet-agent -e "primary switchover T294321"'
```
**Clean up tasks:**
[] Clean up heartbeat table(s).
[] change events for query killer:
```
events_coredb_master.sql on the new primary db1109
events_coredb_slave.sql on the new slave db1104
```
[] Update DNS: FIXME
[] Update candidate primary dbctl notes
```
sudo dbctl instance db1104 set-candidate-master --section s8 true
sudo dbctl instance db1109 set-candidate-master --section s8 false
```
[] Check tendril was updated
[] Check zarcillo was updated
** db-switchover should do this. If it fails, do it manually: https://phabricator.wikimedia.org/P13956
[] Depool OLD primary, as it's running 10.1, replicating from a 10.4 primary
```
sudo dbctl instance db1104 depool
sudo dbctl config commit -m "Depool db1104 until it's reimaged to buster T294321"
```
[] Apply outstanding schema changes to db1104 (if any)
[] Update/resolve this ticket.