Page MenuHomePhabricator

Switchover s2 master (db1222 -> db1162)
Closed, ResolvedPublic

Description

When: During a pre-defined DBA maintenance windows

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

Checklist:

NEW primary: db1162
OLD primary: db1222

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

Failover prep:

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

Failover:

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

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

Details

Event Timeline

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

[operations/puppet@production] mariadb: Promote db1162 to s2 master

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

Marostegui triaged this task as High priority.
Marostegui subscribed.

db1222 paged with index corruption, let's upgrade, rebuild the candidate and switch it.

Mentioned in SAL (#wikimedia-operations) [2025-01-23T13:09:38Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Depool db1162 T384597', diff saved to https://phabricator.wikimedia.org/P72251 and previous config saved to /var/cache/conftool/dbconfig/20250123-130937-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2025-01-23T16:25:52Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Set db1162 with weight 0 T384597', diff saved to https://phabricator.wikimedia.org/P72283 and previous config saved to /var/cache/conftool/dbconfig/20250123-162552-root.json

Mentioned in SAL (#wikimedia-operations) [2025-01-23T16:26:05Z] <marostegui@cumin1002> DONE (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 26 hosts with reason: Primary switchover s2 T384597

Change #1113802 merged by Marostegui:

[operations/puppet@production] mariadb: Promote db1162 to s2 master

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

Mentioned in SAL (#wikimedia-operations) [2025-01-23T16:42:51Z] <marostegui> Starting s2 eqiad failover from db1222 to db1162 - T384597

Mentioned in SAL (#wikimedia-operations) [2025-01-23T16:43:23Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Promote db1162 to s2 primary T384597', diff saved to https://phabricator.wikimedia.org/P72285 and previous config saved to /var/cache/conftool/dbconfig/20250123-164322-root.json

Mentioned in SAL (#wikimedia-operations) [2025-01-23T16:44:16Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Depool db1222 T384597', diff saved to https://phabricator.wikimedia.org/P72286 and previous config saved to /var/cache/conftool/dbconfig/20250123-164415-marostegui.json

Marostegui added a subscriber: jcrespo.

This has been done - but I am leaving the ticket open so I can move db1239:3312 under the new master when it is back in sync with the master after table rebuilds cc @jcrespo

db1239:3312 moved under the new master - this can be closed.