Page MenuHomePhabricator

Switchover x3 master (db2241 -> db2162)
Closed, ResolvedPublic

Description

When: During a pre-defined DBA maintenance windows

Affected wikis:: TO-DO

Checklist:

NEW primary: db2162
OLD primary: db2241

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

Failover prep:

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

Failover:

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

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

Event Timeline

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

[operations/puppet@production] mariadb: Promote db2162 to x3 master

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

Marostegui triaged this task as Medium priority.
Marostegui moved this task from Triage to In progress on the DBA board.

Mentioned in SAL (#wikimedia-operations) [2025-07-16T07:49:32Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Set db2162 with weight 0 T399456', diff saved to https://phabricator.wikimedia.org/P79180 and previous config saved to /var/cache/conftool/dbconfig/20250716-074931-root.json

Mentioned in SAL (#wikimedia-operations) [2025-07-16T07:49:48Z] <marostegui@cumin1002> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 15 hosts with reason: Primary switchover x3 T399456

Change #1169093 merged by Marostegui:

[operations/puppet@production] mariadb: Promote db2162 to x3 master

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

Change #1170082 had a related patch set uploaded (by Marostegui; author: Marostegui):

[operations/puppet@production] db2241: Fix comment

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

Change #1170082 merged by Marostegui:

[operations/puppet@production] db2241: Fix comment

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

Mentioned in SAL (#wikimedia-operations) [2025-07-16T07:54:48Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Promote db2162 to x3 primary T399456', diff saved to https://phabricator.wikimedia.org/P79181 and previous config saved to /var/cache/conftool/dbconfig/20250716-075448-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2025-07-16T07:54:54Z] <marostegui> Starting x3 codfw failover from db2241 to db2162 - T399456

Mentioned in SAL (#wikimedia-operations) [2025-07-16T07:55:35Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Depool db2241 T399456', diff saved to https://phabricator.wikimedia.org/P79182 and previous config saved to /var/cache/conftool/dbconfig/20250716-075534-marostegui.json

Change #1170083 had a related patch set uploaded (by Marostegui; author: Marostegui):

[operations/puppet@production] db2241: Migrate to MariaDB 10.11

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

Marostegui updated the task description. (Show Details)

Done
The migration of the old master will be tracked at T399298

Change #1170083 merged by Marostegui:

[operations/puppet@production] db2241: Migrate to MariaDB 10.11

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