File: rpl_trx_boundary_parser_all_steps.inc

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 (252 lines) | stat: -rw-r--r-- 7,359 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# ==== Purpose ====
#
# This include will insert some data into a table at the master varying the
# debug sync point at slave that will be used to stop the IO thread in the
# middle of transaction event stream (trying to let partial transactions in
# the relay log).
#
# ==== Usage ====
#
# [--let $storage_engine= InnoDB | MyISAM]
# --source extra/rpl_tests/rpl_trx_boundary_parser_all_steps.inc
#
# Parameters:
#   $storage_engine
#     The storage engine that will be used in the CREATE TABLE statement.
#     If not specified, InnoDB will be used.
#

if (!$storage_engine)
{
  --let $_storage_engine= INNODB
}
if ($storage_engine)
{
  --let $_storage_engine= `SELECT UPPER('$storage_engine')`
}
if ( `SELECT '$_storage_engine' <> 'INNODB' AND '$_storage_engine' <> 'MYISAM'` )
{
  --die ERROR IN TEST: invalid value for mysqltest variable 'storage_engine': $storage_engine
}

# Check if SQL thread is running
--source include/rpl_connection_slave.inc
--let $_is_sql_thread_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1)

# If the SQL thread is stopped, we will assert GTIDs based on
# Retrieved_Gtid_Set
if ( $_is_sql_thread_running == No )
{
  --let $assert_on_retrieved_gtid_set= 1
  --let $gtid_step_assert_include=include/gtid_step_assert_on_retrieved.inc
  --let $gtid_step_reset_include=include/gtid_step_reset_on_retrieved.inc
}
if ( $_is_sql_thread_running == Yes )
{
  --let $assert_on_retrieved_gtid_set= 0
  --let $gtid_step_assert_include=include/gtid_step_assert.inc
  --let $gtid_step_reset_include=include/gtid_step_reset.inc
}

--source include/rpl_connection_master.inc
# GTID steps will be based on master's UUID
--let $gtid_step_uuid= `SELECT @@GLOBAL.SERVER_UUID`
--source include/rpl_connection_slave.inc
--source $gtid_step_reset_include

# Creating tables t1 and t2 using $_storage_engine
# Table t1 will log the testcase activity
# Table t2 will be used to insert data to be tested
--source include/rpl_connection_master.inc
--eval CREATE TABLE t1 (i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, info VARCHAR(64)) ENGINE=$_storage_engine
--eval CREATE TABLE t2 (i INT) ENGINE=$_storage_engine

#
# First, we insert some data, restart the slave IO thread and
# sync slave SQL thread (if it is running) with master
# as a normal case just for control.
#

# Insert data without splitting transactions in the relay log
INSERT INTO t1 (info) VALUE ('Insert data without splitting transactions in the relay log');

BEGIN;
INSERT INTO t2 (i) VALUES (-6);
INSERT INTO t2 (i) VALUES (-5);
INSERT INTO t2 (i) VALUES (-4);
COMMIT;

# Check if SQL thread was running before to sync it
if ( $_is_sql_thread_running == Yes )
{
  # Sync SQL thread
  --source include/rpl_connection_master.inc
  --source include/sync_slave_sql_with_master.inc
  --let diff_tables= master:t1, slave:t1
  --source include/diff_tables.inc
}
# Else we sync only the IO thread
if ( $_is_sql_thread_running == No )
{
  # Sync IO thread
  --source include/rpl_connection_master.inc
  --source include/sync_slave_io_with_master.inc
}

# Restart the IO thread not in the middle of transaction
--source include/rpl_connection_slave.inc
--source include/stop_slave_io.inc
--source include/start_slave_io.inc

# Check if the IO thread retrieved the correct amount of GTIDs
--source include/rpl_connection_slave.inc
--let $gtid_step_count= 4
if ($_storage_engine == 'MYISAM')
{
  --let $gtid_step_count= 6
}
--source $gtid_step_assert_include

#
# Second, we make master rotate its binlog
#

# Insert data rotating master binlog between two transactions
--source include/rpl_connection_master.inc
INSERT INTO t1 (info) VALUE ('Insert data rotating master binlog between two transactions');

BEGIN;
INSERT INTO t2 (i) VALUES (-3);
INSERT INTO t2 (i) VALUES (-2);
COMMIT;
FLUSH LOGS;
INSERT INTO t1 (info) VALUE ('After FLUSH LOGS at master');
BEGIN;
INSERT INTO t2 (i) VALUES (-1);
INSERT INTO t2 (i) VALUES (0);
COMMIT;

# Check if SQL thread was running before to sync it
if ( $_is_sql_thread_running == Yes )
{
  # Sync SQL thread
  --source include/rpl_connection_master.inc
  --source include/sync_slave_sql_with_master.inc
  --let diff_tables= master:t1, slave:t1
  --source include/diff_tables.inc
}
# Else we sync only the IO thread
if ( $_is_sql_thread_running == No )
{
  # Sync IO thread
  --source include/rpl_connection_master.inc
  --source include/sync_slave_io_with_master.inc
}

# Restart the IO thread again, not in the middle of transaction
--source include/rpl_connection_slave.inc
--source include/stop_slave_io.inc
--source include/start_slave_io.inc

# Check if the IO thread retrieved the correct amount of GTIDs
--source include/rpl_connection_slave.inc
--let $gtid_step_count= 4
if ($_storage_engine == 'MYISAM')
{
  # We will expect a different amount of GTIDs, as the non-transactional
  # storage engine will "ignore" the BEGIN/COMMIT boundaries and will
  # generate one transaction for each INSERT statement.
  --let $gtid_step_count= 6
}
--source $gtid_step_assert_include

#
# Third, let's go with splitting transactions
#

--let $info_table= t1
--let $table= t2
--let $counter= 0

# Stop after GTID, just if GTIDs are enabled
--inc $counter
--let $debug_point= stop_io_after_reading_gtid_log_event
--let $gtids_after_stop= 1
--let $gtids_after_sync= 2
if ($_storage_engine == 'MYISAM')
{
  --let $gtids_after_sync= 3
}
--source extra/rpl_tests/rpl_trx_boundary_parser_one_step.inc

# Stop after BEGIN query
--inc $counter
--let $debug_point= stop_io_after_reading_query_log_event
--let $gtids_after_stop= 1
--let $gtids_after_sync= 2
if ($_storage_engine == 'MYISAM')
{
  --let $gtids_after_sync= 3
}
--source extra/rpl_tests/rpl_trx_boundary_parser_one_step.inc

# Stop after USER_VAR, just for SBR
if ( `SELECT @@GLOBAL.binlog_format = 'STATEMENT'` )
{
  --inc $counter
  --let $debug_point= stop_io_after_reading_user_var_log_event
  --let $gtids_after_stop= 1
  --let $gtids_after_sync= 2
  if ($_storage_engine == 'MYISAM')
  {
    --let $gtids_after_stop= 2
    --let $gtids_after_sync= 2
  }
  --source extra/rpl_tests/rpl_trx_boundary_parser_one_step.inc
}

# Stop after TABLE_MAP, just for RBR
if ( `SELECT @@GLOBAL.binlog_format = 'ROW'` )
{
  --inc $counter
  --let $debug_point= stop_io_after_reading_table_map_event
  --let $gtids_after_stop= 1
  --let $gtids_after_sync= 2
  if ($_storage_engine == 'MYISAM')
  {
    --let $gtids_after_stop= 1
    --let $gtids_after_sync= 3
  }
  --source extra/rpl_tests/rpl_trx_boundary_parser_one_step.inc
}

# Stop after XID, just for InnoDB tables
if ( $_storage_engine == 'INNODB' )
{
  --inc $counter
  --let $debug_point= stop_io_after_reading_xid_log_event
  --let $gtids_after_stop= 2
  --let $gtids_after_sync= 1
  --source extra/rpl_tests/rpl_trx_boundary_parser_one_step.inc
}

# Check if SQL thread was running before to sync it
if ( $_is_sql_thread_running == Yes )
{
  # Sync SQL thread
  --source include/rpl_connection_master.inc
  --source include/sync_slave_sql_with_master.inc
  --let diff_tables= master:t1, slave:t1
  --source include/diff_tables.inc
}

# Dropping tables t1 and t2
--source include/rpl_connection_master.inc
DROP TABLE t1,t2;

# Check if SQL thread was running before to sync it
if ( $_is_sql_thread_running == Yes )
{
  # Let the slave to sync with the master before exiting the include
  --source include/sync_slave_sql_with_master.inc
}