Page MenuHomePhabricator

Switchover x4 master (db2248 -> db2245)
Closed, InvalidPublic

Description

When: During a pre-defined DBA maintenance windows

Affected wikis:: TO-DO

Checklist:

NEW primary: db2245
OLD primary: db2248

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

Failover prep:

  • Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover x4 T437696" 'A:db-section-x4'
  • Set NEW primary with weight 0
sudo dbctl instance db2245 set-weight 0
sudo dbctl config commit -m "Set db2245 with weight 0 T437696"
  • 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 db2248 db2245
  • Disable puppet on both nodes
sudo cumin 'db2248* or db2245*' 'disable-puppet "primary switchover T437696"'
  • Merge gerrit puppet change to promote NEW primary: FIXME
ssh puppetserver1001.eqiad.wmnet
sudo puppet-merge

Failover:

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

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

Event Timeline

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

[operations/puppet@production] mariadb: Promote db2245 to x4 master

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

Change #1339674 abandoned by Marostegui:

[operations/puppet@production] mariadb: Promote db2245 to x4 master

Reason:

Not needed

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

Marostegui subscribed.

This was a test