Page MenuHomePhabricator

Switchover s5 master (db2213 -> db2157)
Closed, ResolvedPublic

Description

When: During a pre-defined DBA maintenance windows

Affected wikis:: https://noc.wikimedia.org/conf/highlight.php?file=dblists/s5.dblist

Checklist:

NEW primary: db2157
OLD primary: db2213

  • Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=db2213.codfw.wmnet h=db2157.codfw.wmnet

Failover prep:

  • Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover s5 T437188" 'A:db-section-s5'
  • Set NEW primary with weight 0
sudo dbctl instance db2157 set-weight 0
sudo dbctl config commit -m "Set db2157 with weight 0 T437188"
  • Topology changes, move all replicas under NEW primary, open orchestartor to monitor the process and check it at the end.
sudo db-switchover --timeout=25 --replicating-master --read-only-master --only-slave-move db2213 db2157
  • Disable puppet on both nodes
sudo cumin 'db2213* or db2157*' 'disable-puppet "primary switchover T437188"'
ssh puppetserver1001.eqiad.wmnet
sudo puppet-merge

Failover:

  • Log the failover:
!log Starting s5 codfw failover from db2213 to db2157 - T437188
  • Switch primaries:
sudo db-switchover --replicating-master --read-only-master --skip-slave-move db2213 db2157
echo "===== db2213 (OLD)"; sudo db-mysql db2213 -e 'show slave status\G'
echo "===== db2157 (NEW)"; sudo db-mysql db2157 -e 'show slave status\G'
  • Promote NEW primary in dbctl
sudo dbctl --scope codfw section s5 set-master db2157
sudo dbctl config commit -m "Promote db2157 to s5 primary T437188"
  • Clean up heartbeat table(s).
sudo db-mysql db2157 heartbeat -e "delete from heartbeat where file like 'db2213%';"
  • Restart puppet on both hosts:
sudo cumin 'db2213* or db2157*' 'run-puppet-agent -e "primary switchover T437188"'

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 db2157
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 db2213
  • Update candidate primary dbctl and orchestrator notes
sudo dbctl instance db2213 set-candidate-master --section s5 true
sudo dbctl instance db2157 set-candidate-master --section s5 false
sudo cumin 'dborch*' 'orchestrator-client -c untag -i db2157 --tag name=candidate'
sudo cumin 'dborch*' 'orchestrator-client -c tag -i db2213 --tag name=candidate'
sudo db-mysql db1215 zarcillo -e "select * from masters where section = 's5';"
  • Depool db2213 for maintenance.
sudo dbctl instance db2213 depool
sudo dbctl config commit -m "Depool db2213 T437188"
  • Change db2213 weight to mimic the previous weight db2157:
sudo dbctl instance db2213 edit
  • Slowly repool the db2213 if ready
sudo cookbook sre.mysql.pool -t T437188 -r "Repooling after switchover" db2213
  • Update/resolve this ticket.

Event Timeline

Change #1337452 had a related patch set uploaded (by Gerrit maintenance bot; author: Gerrit maintenance bot):

[operations/puppet@production] mariadb: Promote db2157 to s5 master

https://gerrit.wikimedia.org/r/1337452

Mentioned in SAL (#wikimedia-operations) [2026-09-07T08:34:35Z] <marostegui@cumin1003> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 28 hosts with reason: Primary switchover s5 T437188

Mentioned in SAL (#wikimedia-operations) [2026-09-07T08:34:49Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Set db2157 with weight 0 T437188', diff saved to https://phabricator.wikimedia.org/P96353 and previous config saved to /var/cache/conftool/dbconfig/20260907-083448-marostegui.json

Change #1337452 merged by Marostegui:

[operations/puppet@production] mariadb: Promote db2157 to s5 master

https://gerrit.wikimedia.org/r/1337452

Mentioned in SAL (#wikimedia-operations) [2026-09-07T08:38:02Z] <marostegui> Starting s5 codfw failover from db2213 to db2157 - T437188

Mentioned in SAL (#wikimedia-operations) [2026-09-07T08:38:26Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Promote db2157 to s5 primary T437188', diff saved to https://phabricator.wikimedia.org/P96354 and previous config saved to /var/cache/conftool/dbconfig/20260907-083825-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2026-09-07T08:39:05Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Depool db2213 T437188', diff saved to https://phabricator.wikimedia.org/P96355 and previous config saved to /var/cache/conftool/dbconfig/20260907-083904-marostegui.json

Starting pool of db2213 by marostegui@cumin1003: Repooling after switchover

Completed pooling of db2213 by marostegui@cumin1003: Repooling after switchover

This was done but I never closed the task