Page MenuHomePhabricator

Switchover x1 master (db2196 -> db2215)
Closed, ResolvedPublic

Description

When: During a pre-defined DBA maintenance windows

Affected wikis:: TO-DO

Checklist:

NEW primary: db2215
OLD primary: db2196

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

Failover prep:

  • Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover x1 T400514" 'A:db-section-x1'
  • Set NEW primary with weight 0
sudo dbctl instance db2215 set-weight 0
sudo dbctl config commit -m "Set db2215 with weight 0 T400514"
  • Depool NEW from any specific group (API, vslow, dump) if present.
sudo dbctl instance db2215 edit
# If some changes were made:
sudo dbctl config commit -m "Remove db2215 from API/vslow/dump T400514"
  • Topology changes, move all replicas under NEW primary
sudo db-switchover --timeout=25 --replicating-master --read-only-master --only-slave-move db2196 db2215
  • Disable puppet on both nodes
sudo cumin 'db2196* or db2215*' 'disable-puppet "primary switchover T400514"'

Failover:

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

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 db2215
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 db2196
  • Update candidate primary dbctl and orchestrator notes
sudo dbctl instance db2196 set-candidate-master --section x1 true
sudo dbctl instance db2215 set-candidate-master --section x1 false
sudo cumin 'dborch*' 'orchestrator-client -c untag -i db2215 --tag name=candidate'
sudo cumin 'dborch*' 'orchestrator-client -c tag -i db2196 --tag name=candidate'
sudo db-mysql db1215 zarcillo -e "select * from masters where section = 'x1';"
  • (If needed): Depool db2196 for maintenance.
sudo dbctl instance db2196 depool
sudo dbctl config commit -m "Depool db2196 T400514"
  • Change db2196 weight to mimic the previous weight db2215 (main/api/vslow/dumps):
sudo dbctl instance db2196 edit
  • Update/resolve this ticket.

Details

Event Timeline

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

[operations/puppet@production] mariadb: Promote db2215 to x1 master

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

Mentioned in SAL (#wikimedia-operations) [2025-07-25T22:28:56Z] <marostegui@cumin1002> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 14 hosts with reason: Primary switchover x1 T400514

Mentioned in SAL (#wikimedia-operations) [2025-07-25T22:29:01Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Set db2215 with weight 0 T400514', diff saved to https://phabricator.wikimedia.org/P79995 and previous config saved to /var/cache/conftool/dbconfig/20250725-222856-root.json

Change #1172721 merged by Marostegui:

[operations/puppet@production] mariadb: Promote db2215 to x1 master

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

Mentioned in SAL (#wikimedia-operations) [2025-07-25T22:35:57Z] <marostegui> Starting x1 codfw failover from db2196 to db2215 - T400514

Mentioned in SAL (#wikimedia-operations) [2025-07-25T22:36:23Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Promote db2215 to x1 primary T400514', diff saved to https://phabricator.wikimedia.org/P79996 and previous config saved to /var/cache/conftool/dbconfig/20250725-223622-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2025-07-25T22:37:36Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Depool db2196 T400514', diff saved to https://phabricator.wikimedia.org/P79997 and previous config saved to /var/cache/conftool/dbconfig/20250725-223736-marostegui.json