File: rpl_ps_worker_stop_slave.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (184 lines) | stat: -rw-r--r-- 8,770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# === Purpose ===
#
# The purpose of this test is assess the behaviour of the information on the
# performance_schema table replication_applier_status_by_worker after the
# STOP SLAVE command both for a single thread slave and for a multi-threaded
# slave.
#
# === Implementation ===
#
# We test four scenarios in which we stop and start the slave, changing between
# STS and MTS or keeping the number of workers. In each scenario, we test is the
# values after the stop slave and after the start slave are as expected.
#
# === References ===
#
# BUG#28191382 LAST_APPLIED_TRANSACTION* AND APPLYING_TRANSACTION* ARE PRESERVED
#              ON START SLAVE


# the test in binlog format agnostic
--source include/have_binlog_format_row.inc
--source include/not_rpl_gtid_only.inc
--source include/master-slave.inc

CREATE TABLE t1 (a INT);
--source include/sync_slave_sql_with_master.inc

--source include/rpl_connection_slave.inc
SET @saved_replica_parallel_workers = @@GLOBAL.replica_parallel_workers;
--source include/stop_slave.inc
SET @@GLOBAL.replica_parallel_workers = 0;
--source include/start_slave.inc

# Four scenarios are tested:
# Scenario 1:
#  - Switch: STS to STS
#  - Expected outcome: the values must be preserved after START SLAVE
# Scenario 2:
#  - Switch: STS to MTS
#  - Expected outcome: the values must be cleared after START SLAVE
# Scenario 3:
#  - Switch: MTS to MTS
#  - Expected outcome: the values must be cleared after START SLAVE
# Scenario 4:
#  - Switch: MTS to STS
#  - Expected outcome: the values must be cleared after START SLAVE
#
# In all four scenarios the values must be preserved after STOP SLAVE

--let $ps_table = performance_schema.replication_applier_status_by_worker
--let $scenario = 1
--let $new_replica_parallel_workers = 0

while ($scenario < 5)
{
  if ($scenario == 2)
  {
    --let $new_replica_parallel_workers = 1
  }
  if ($scenario == 4)
  {
    --let $new_replica_parallel_workers = 0
  }

  --source include/rpl_connection_master.inc
  --eval INSERT INTO t1 VALUES ($scenario)
  --source include/sync_slave_sql_with_master.inc

  --let $last_applied_trx_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1)
  --let $last_applied_trx_OCT_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_ICT_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_start_apply_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_end_apply_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1)

  --source include/stop_slave.inc
  --eval SET @@GLOBAL.replica_parallel_workers = $new_replica_parallel_workers

  --let $last_applied_trx_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1)
  --let $last_applied_trx_OCT_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_ICT_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_start_apply_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_end_apply_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1)

  --source include/start_slave.inc

  --let $last_applied_trx_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1)
  --let $last_applied_trx_OCT_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_ICT_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_start_apply_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1)
  --let $last_applied_trx_end_apply_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1)

  --let $assert_cond = "$last_applied_trx_1" = "$last_applied_trx_2"
  --let $assert_text = The GTID information about the last applied transaction was preserved after the slave was stopped
  --source include/assert.inc

  --let $assert_cond = "$last_applied_trx_OCT_1" = "$last_applied_trx_OCT_2"
  --let $assert_text = The OCT information about the last applied transaction was preserved after the slave was stopped
  --source include/assert.inc

  --let $assert_cond = "$last_applied_trx_ICT_1" = "$last_applied_trx_ICT_2"
  --let $assert_text = The ICT information about the last applied transaction was preserved after the slave was stopped
  --source include/assert.inc

  --let $assert_cond = "$last_applied_trx_start_apply_1" = "$last_applied_trx_start_apply_2"
  --let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was stopped
  --source include/assert.inc

  --let $assert_cond = "$last_applied_trx_end_apply_1" = "$last_applied_trx_end_apply_2"
  --let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was stopped
  --source include/assert.inc

  if ($scenario == 1)
  {
    --let $assert_cond = "$last_applied_trx_2" = "$last_applied_trx_3"
    --let $assert_text = The GTID information about the last applied transaction was preserved after the slave was started
  }
  if ($scenario != 1)
  {
    --let $assert_cond = "$last_applied_trx_3" = ""
    --let $assert_text = The GTID information about the last applied transaction was cleared after the slave was started
  }
  --source include/assert.inc

  if ($scenario == 1)
  {
    --let $assert_cond = "$last_applied_trx_OCT_2" = "$last_applied_trx_OCT_3"
    --let $assert_text = The OCT information about the last applied transaction was preserved after the slave was started
  }
  if ($scenario != 1)
  {
    --let $assert_cond = "$last_applied_trx_OCT_3" = "0000-00-00 00:00:00.000000"
    --let $assert_text = The OCT information about the last applied transaction was cleared after the slave was started
  }
  --source include/assert.inc

  if ($scenario == 1)
  {
    --let $assert_cond = "$last_applied_trx_ICT_2" = "$last_applied_trx_ICT_3"
    --let $assert_text = The ICT information about the last applied transaction was preserved after the slave was started
  }
  if ($scenario != 1)
  {
    --let $assert_cond = "$last_applied_trx_ICT_3" = "0000-00-00 00:00:00.000000"
    --let $assert_text = The ICT information about the last applied transaction was cleared after the slave was started
  }
  --source include/assert.inc

  if ($scenario == 1)
  {
    --let $assert_cond = "$last_applied_trx_start_apply_2" = "$last_applied_trx_start_apply_3"
    --let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was started
  }
  if ($scenario != 1)
  {
    --let $assert_cond = "$last_applied_trx_start_apply_3" = "0000-00-00 00:00:00.000000"
    --let $assert_text = The start apply timestamp information about the last applied transaction was cleared after the slave was started
  }
  --source include/assert.inc

  if ($scenario == 1)
  {
    --let $assert_cond = "$last_applied_trx_end_apply_2" = "$last_applied_trx_end_apply_3"
    --let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was started
  }
  if ($scenario != 1)
  {
    --let $assert_cond = "$last_applied_trx_end_apply_3" = "0000-00-00 00:00:00.000000"
    --let $assert_text = The end apply timestamp information about the last applied transaction was cleared after the slave was started
  }
  --source include/assert.inc

  --inc $scenario
}

# cleanup
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/sync_slave_sql_with_master.inc
--source include/stop_slave.inc
--disable_warnings
SET @@GLOBAL.replica_parallel_workers = @saved_replica_parallel_workers;
--enable_warnings
--source include/start_slave.inc
--source include/rpl_end.inc