Page MenuHomePhabricator

Switchover es4 codfw master (es2020 -> es2021)
Closed, ResolvedPublic

Description

When: Anytime - not in use for writes

Checklist:

NEW primary: es2021
OLD primary: es2020

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

Failover prep:

  • Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover es4 T364451" 'A:db-section-es4'
  • Set NEW primary with weight 0 (and depool it from API or vslow/dump groups if it is present).
sudo dbctl instance es2021 set-weight 0
sudo dbctl config commit -m "Set es2021 with weight 0 T364451"
  • Topology changes, move all replicas under NEW primary
sudo db-switchover --read-only-master --replicating-master --timeout=25 --only-slave-move es2020 es2021
  • Disable puppet on both nodes
sudo cumin 'es2021* or es2020*' 'disable-puppet "primary switchover T364451"'

Failover:

  • Log the failover:
!log Starting es4 codfw failover from es2020 to es2021 - T364451
  • Switch primaries:
sudo db-switchover --read-only-master --replicating-master  --skip-slave-move es2020 es2021
echo "===== es2020 (OLD)"; sudo db-mysql es2020 -e 'show slave status\G'
echo "===== es2021 (NEW)"; sudo db-mysql es2021 -e 'show slave status\G'
  • Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope codfw section es4 set-master es2021
sudo dbctl config commit -m "Promote es2021 to es4 primary and set section read-write T364451"
  • Restart puppet on both hosts:
sudo cumin 'es2021* or es2020*' 'run-puppet-agent -e "primary switchover T364451"'

Clean up tasks:

  • Clean up heartbeat table(s).
sudo db-mysql es2021 heartbeat -e "delete from heartbeat where file like 'es2020%';"
  • change events for query killer:
events_coredb_master.sql on the new primary es2021
events_coredb_slave.sql on the new slave es2020
  • Update candidate primary dbctl and orchestrator notes
sudo dbctl instance es2020 set-candidate-master --section es4 true
sudo dbctl instance es2021 set-candidate-master --section es4 false
(dborch1001): sudo orchestrator-client -c untag -i es2021 --tag name=candidate
(dborch1001): sudo orchestrator-client -c tag -i es2020 --tag name=candidate
sudo db-mysql db1115 zarcillo -e "select * from masters where section = 'es4';"
  • (If needed): Depool es2020 for maintenance.
sudo dbctl instance es2020 depool
sudo dbctl config commit -m "Depool es2020 T364451"
  • Change es2021 weight to mimic the previous weight es2020:
sudo dbctl instance es2021 edit
  • Update/resolve this ticket.

Event Timeline

Marostegui triaged this task as Medium priority.May 8 2024, 8:27 AM
Marostegui updated the task description. (Show Details)
Marostegui moved this task from Triage to Ready on the DBA board.

I will do this tomorrow. I don't want to switch both es4 and es5 the same day.

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:14:55Z] <marostegui@cumin1002> START - Cookbook sre.hosts.downtime for 1:00:00 on 6 hosts with reason: Primary switchover es4 T364451

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:15:01Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Set es2021 with weight 0 T364451', diff saved to https://phabricator.wikimedia.org/P62170 and previous config saved to /var/cache/conftool/dbconfig/20240509-061500-root.json

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:15:12Z] <marostegui@cumin1002> END (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 6 hosts with reason: Primary switchover es4 T364451

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

[operations/puppet@production] mariadb: Promote es2021 to es4 codfw master

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

Change #1029434 merged by Marostegui:

[operations/puppet@production] mariadb: Promote es2021 to es4 codfw master

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

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:18:31Z] <marostegui> Starting es4 codfw failover from es2020 to es2021 - T364451

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:19:05Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Promote es2021 to es4 primary and set section read-write T364451', diff saved to https://phabricator.wikimedia.org/P62172 and previous config saved to /var/cache/conftool/dbconfig/20240509-061904-marostegui.json

Mentioned in SAL (#wikimedia-operations) [2024-05-09T06:19:59Z] <marostegui@cumin1002> dbctl commit (dc=all): 'Depool es2020 T364451', diff saved to https://phabricator.wikimedia.org/P62173 and previous config saved to /var/cache/conftool/dbconfig/20240509-061957-root.json

Marostegui updated the task description. (Show Details)

This is done

Mentioned in SAL (#wikimedia-operations) [2024-05-14T09:51:43Z] <marostegui@cumin1002> START - Cookbook sre.hosts.downtime for 0:05:00 on 6 hosts with reason: Primary switchover es4 T364451

Mentioned in SAL (#wikimedia-operations) [2024-05-14T09:52:01Z] <marostegui@cumin1002> END (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 0:05:00 on 6 hosts with reason: Primary switchover es4 T364451

The above two !log can be ignored, they belong to a different task