Page MenuHomePhabricator

Switchover es7 master (es2039 -> es2038)
Closed, ResolvedPublic

Description

When: Anytime - no in use

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

Checklist:

NEW primary: es2038
OLD primary: es2039

  • Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=es2039.codfw.wmnet h=es2038.codfw.wmnet
$ sudo pt-config-diff --defaults-file /root/.my.cnf h=es2039.codfw.wmnet h=es2038.codfw.wmnet
16 config differences
Variable                  es2039                    es2038
========================= ========================= =========================
general_log_file          es2039.log                es2038.log
gtid_binlog_pos           172005380-172005380-39... 172005380-172005380-39...
gtid_binlog_state         172005380-172005380-39... 172005380-172005380-39...
gtid_current_pos          0-171966521-9791330871... 0-171966521-9791330871...
gtid_domain_id            180367486                 180363306
gtid_slave_pos            0-171966521-9791330871... 0-171966521-9791330871...
hostname                  es2039                    es2038
log_bin_basename          /srv/sqldata/es2039-bin   /srv/sqldata/es2038-bin
log_bin_index             /srv/sqldata/es2039-bi... /srv/sqldata/es2038-bi...
pid_file                  /srv/sqldata/es2039.pid   /srv/sqldata/es2038.pid
report_host               es2039.codfw.wmnet        es2038.codfw.wmnet
rpl_semi_sync_master_e... ON                        OFF
rpl_semi_sync_slave_en... OFF                       ON
server_id                 180367486                 180363306
slow_query_log_file       es2039-slow.log           es2038-slow.log
wsrep_node_name           es2039                    es2038

Failover prep:

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

Failover:

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

Clean up tasks:

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

Details

Event Timeline

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

[operations/puppet@production] mariadb: Promote es2038 to es7 master

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

ABran-WMF changed the task status from Open to In Progress.Sep 12 2024, 5:56 AM
ABran-WMF claimed this task.
ABran-WMF triaged this task as High priority.
ABran-WMF updated the task description. (Show Details)
ABran-WMF moved this task from Triage to In progress on the DBA board.

Mentioned in SAL (#wikimedia-operations) [2024-09-12T05:58:21Z] <arnaudb@cumin1002> START - Cookbook sre.hosts.downtime for 1:00:00 on 6 hosts with reason: Primary switchover es7 T374592

Mentioned in SAL (#wikimedia-operations) [2024-09-12T05:58:38Z] <arnaudb@cumin1002> END (PASS) - Cookbook sre.hosts.downtime (exit_code=0) for 1:00:00 on 6 hosts with reason: Primary switchover es7 T374592

Mentioned in SAL (#wikimedia-operations) [2024-09-12T05:59:04Z] <arnaudb@cumin1002> dbctl commit (dc=all): 'Set es2038 with weight 0 T374592', diff saved to https://phabricator.wikimedia.org/P69010 and previous config saved to /var/cache/conftool/dbconfig/20240912-055903-arnaudb.json

ABran-WMF updated the task description. (Show Details)

Change #1072337 merged by Arnaudb:

[operations/puppet@production] mariadb: Promote es2038 to es7 master

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

Mentioned in SAL (#wikimedia-operations) [2024-09-12T06:02:25Z] <arnaudb> Starting es7 codfw failover from es2039 to es2038 - T374592

Mentioned in SAL (#wikimedia-operations) [2024-09-12T06:03:09Z] <arnaudb@cumin1002> dbctl commit (dc=all): 'Promote es2038 to es7 primary and set section read-write T374592', diff saved to https://phabricator.wikimedia.org/P69012 and previous config saved to /var/cache/conftool/dbconfig/20240912-060308-arnaudb.json

Mentioned in SAL (#wikimedia-operations) [2024-09-12T06:05:51Z] <arnaudb@cumin1002> dbctl commit (dc=all): 'T374592', diff saved to https://phabricator.wikimedia.org/P69013 and previous config saved to /var/cache/conftool/dbconfig/20240912-060550-arnaudb.json

ABran-WMF updated the task description. (Show Details)
ABran-WMF moved this task from In progress to Done on the DBA board.