File: rpl_gtid_parallel.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 (188 lines) | stat: -rw-r--r-- 4,938 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
#Want to skip this test from daily Valgrind execution
--source include/no_valgrind_without_big.inc
# ==== Purpose ====
#
# Stress-test concurrent re-execution of transactions generated with
# GTID_MODE = ON.
#
# ==== Implementation ====
#
# 1. Generate a load on the master consisting of:
#     - transactions (INSERT/UPDATE/DELETE)
#     - DDL (ALTER and RENAME)
#     - FLUSH LOGS
#    Do not replicate anything.
#
# 2. Apply the binary logs on the slave (which is fresh).  The binary
#    logs are applied in N parallel connections.  In addition, for
#    increased concurrency, we open N concurrent connections that
#    repeatedly execute SHOW SLAVE STATUS, and N concurrent
#    connections that repeatedly read @@GLOBAL.GTID_EXECUTED and
#    @@GLOBAL.GTID_PURGED.
#
# 3. Check that master and slave have the same data.
#
# ==== References ====
#
# Implemented as part of WL#3584: Global Transaction Identifiers

--source include/not_group_replication_plugin.inc
--source include/not_rpl_gtid_only.inc
--source include/big_test.inc
--source include/not_windows.inc
--source include/not_have_privilege_checks_user.inc
--source include/master-slave.inc

--echo ==== Configure ====

--let $max_iterations= 10000
--let $max_seconds= 100
--let $n_forks= 8
--let $flush_probability= 0.05
--let $rename_probability= 0.1

--echo ==== Initialize ====

--enable_connect_log
--connection slave
--source include/stop_slave.inc

--delimiter |
CREATE PROCEDURE show_slave_status ()
BEGIN
  DECLARE name VARCHAR(100) DEFAULT('');
  WHILE name = '' DO
    SHOW SLAVE STATUS;
    SELECT TABLE_NAME INTO name
      FROM INFORMATION_SCHEMA.TABLES
      WHERE TABLE_NAME = 't_end';
  END WHILE;
END|

CREATE PROCEDURE read_gtid_executed ()
BEGIN
  DECLARE name VARCHAR(100) DEFAULT('');
  DECLARE temp VARCHAR(10000) DEFAULT('');
  WHILE name = '' DO
    SET temp = @@GLOBAL.GTID_EXECUTED;
    SET temp = @@GLOBAL.GTID_OWNED;
    SELECT TABLE_NAME INTO name
      FROM INFORMATION_SCHEMA.TABLES
      WHERE TABLE_NAME = 't_end';
  END WHILE;
END|
--delimiter ;

--connection master

--let $t= 1
eval CREATE TABLE t1_$t (a INT) ENGINE = InnoDB;
eval CREATE TABLE t2_$t (a INT) ENGINE = InnoDB;
eval INSERT INTO t1_$t VALUES (0);
eval INSERT INTO t2_$t VALUES (0);

--echo ==== Generate binary log ====

--let $iteration= 1
--let $start_time= `SELECT UNIX_TIMESTAMP()`
--let $done= 0
--disable_query_log
while (!$done)
{
  --let $rand_type= decide
  --let $rand_probability= $rename_probability
  --source include/rand.inc
  if ($rand)
  {
    --let $last_t= $t
    --inc $t
    eval ALTER TABLE t1_$last_t RENAME TO t1_$t;
    eval RENAME TABLE t2_$last_t TO t2_$t;
  }
  BEGIN;
  eval INSERT INTO t2_$t VALUES ($iteration);
  eval UPDATE t1_$t SET a = $iteration WHERE a = $iteration - 1;
  eval DELETE FROM t2_$t WHERE a = $iteration - 1;
  COMMIT;

  --let $rand_type= decide
  --let $rand_probability= $flush_probability
  --source include/rand.inc
  if ($rand)
  {
    FLUSH LOGS;
  }
  --inc $iteration

  if ($iteration >= $max_iterations)
  {
    --let $done= 1
  }
  if (`SELECT UNIX_TIMESTAMP() - $start_time > $max_seconds`)
  {
    --let $done= 1
  }
}
--enable_query_log
CREATE TABLE t_end (a INT);

--echo ==== Apply the generated binary logs ====

--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
--let $data_dir= `SELECT @@datadir`
--let _BINLOG_FILE= $data_dir/$binlog_file
--let _N_FORKS= $n_forks

perl;
  my $mysql_pipe= "| $ENV{MYSQL} --defaults-group-suffix=.2";
  my $file= $ENV{_BINLOG_FILE};
  $file=~ s/0*([1-9][0-9]*)$//;
  my $number= $1;
  my @mysqlbinlog_commands=
    map { sprintf("$ENV{MYSQL_BINLOG} %s%06d", $file, $_) } 1 .. $number;
  my $n_forks= $ENV{_N_FORKS};
  my $n= $n_forks;
  my @cmd_lists= ( [ 'echo "USE test; CALL show_slave_status();"' ],
                   [ 'echo "USE test; CALL read_gtid_executed();"' ],
                   \@mysqlbinlog_commands,
                   \@mysqlbinlog_commands );
  $n-- while $n && fork;
  my $cmd_list= $cmd_lists[$n % @cmd_lists];
  for my $cmd (@$cmd_list)
  {
    # discard stdout from $cmd (redirect to /dev/null is not portable)
    `$cmd $mysql_pipe`;
    $? == 0 or die "Error executing running $cmd (n=$n): $!";
  }
EOF

--echo ==== Wait for load to finish ====

--connection slave
--let $show_statement= SHOW TABLES;
--let $field= Tables_in_test
--let $condition= t_end
--source include/wait_show_condition.inc

--echo ==== Check result ====

--let $diff_tables= master:t1_$t, master:t2_$t, slave:t1_$t, slave:t2_$t
--let $diff_tables_silent= 1
--source include/diff_tables.inc

--echo ==== Clean up ====

--connection master
--disable_query_log
eval DROP TABLE t1_$t, t2_$t;
--enable_query_log
DROP TABLE t_end;

--connection slave
--disable_query_log
eval DROP TABLE t1_$t, t2_$t;
--enable_query_log
DROP TABLE t_end;
DROP PROCEDURE show_slave_status;
DROP PROCEDURE read_gtid_executed;
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0;