Page MenuHomePhabricator

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

Description

When: During a pre-defined DBA maintenance windows

Prerequisites: https://wikitech.wikimedia.org/wiki/MariaDB/Primary_switchover

Affected wikis:: TO-DO

Checklist:

NEW primary: db2191
OLD primary: db2215

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

Failover prep:

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

Failover:

  • Log the failover:
!log Starting x1 codfw failover from db2215 to db2191 - T409168
  • Set section read-only:
sudo dbctl --scope eqiad section x1 ro "Maintenance until 06:15 UTC - T409168"
sudo dbctl --scope codfw section x1 ro "Maintenance until 06:15 UTC - T409168"
sudo dbctl config commit -m "Set x1 codfw as read-only for maintenance - T409168"
  • Check x1 is indeed read-only
  • Switch primaries:
sudo db-switchover --skip-slave-move db2215 db2191
echo "===== db2215 (OLD)"; sudo db-mysql db2215 -e 'show slave status\G'
echo "===== db2191 (NEW)"; sudo db-mysql db2191 -e 'show slave status\G'
  • Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope codfw section x1 set-master db2191
sudo dbctl --scope eqiad section x1 rw
sudo dbctl --scope codfw section x1 rw
sudo dbctl config commit -m "Promote db2191 to x1 primary and set section read-write T409168"
  • Clean up heartbeat table(s).
sudo db-mysql db2191 heartbeat -e "delete from heartbeat where file like 'db2215%';"
  • Restart puppet on both hosts:
sudo cumin 'db2215* or db2191*' 'run-puppet-agent -e "primary switchover T409168"'

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

Event Timeline

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

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

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

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

[operations/dns@master] wmnet: Update x1-master alias

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

Marostegui triaged this task as Medium priority.Nov 4 2025, 12:51 PM
Marostegui moved this task from Triage to Ready on the DBA board.

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:22:31Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Set db2191 with weight 0 T409168', diff saved to https://phabricator.wikimedia.org/P84816 and previous config saved to /var/cache/conftool/dbconfig/20251105-062230-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:22:53Z] <marostegui@cumin1003> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 14 hosts with reason: Primary switchover x1 T409168

Change #1201593 merged by Marostegui:

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

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

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:27:23Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Set x1 codfw as read-only for maintenance - T409168', diff saved to https://phabricator.wikimedia.org/P84817 and previous config saved to /var/cache/conftool/dbconfig/20251105-062723-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:27:46Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Promote db2191 to x1 primary and set section read-write T409168', diff saved to https://phabricator.wikimedia.org/P84818 and previous config saved to /var/cache/conftool/dbconfig/20251105-062745-marostegui.json

Change #1201594 merged by Marostegui:

[operations/dns@master] wmnet: Update x1-master alias

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

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:29:21Z] <marostegui@cumin1003> dbctl commit (dc=all): 'Depool db2215 T409168', diff saved to https://phabricator.wikimedia.org/P84819 and previous config saved to /var/cache/conftool/dbconfig/20251105-062920-marostegui.json

Marostegui updated the task description. (Show Details)

Done

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:32:03Z] <marostegui@cumin1003> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 14 hosts with reason: Primary switchover x1 T409168

Mentioned in SAL (#wikimedia-operations) [2025-11-05T06:32:29Z] <marostegui@cumin1003> DONE (ERROR) - Cookbook sre.hosts.downtime (exit_code=97) for 1:00:00 on 14 hosts with reason: Primary switchover x1 T409168