File: rpl_mts_spco_alter_table_commands.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 (127 lines) | stat: -rw-r--r-- 4,619 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
# ==== Purpose ====
#
# Auxiliary file sourced for rpl_mts_spco_alter_table_commands_binlog
# and rpl_mts_spco_alter_table_commands_nobinlog tests to check if
# ALTER TABLE variant commands respect replica-preserve-commit-order.
#
# === Requirements ====
#
# This test uses std_data/alter_table.csv which contains ALTER TABLE commands
#
# This test uses extra/rpl_tests/rpl_mts_replica_preserve_commit_order_nobinlog.inc
# to check the ordering of commits.
#
# === Implementation ====
#
# 1. Start replica-preserve-commit-order enabled slave with 8 worker threads.
#
# 2. On master, CREATE TABLE commands and Load ALTER TABLE variant SQL commands
#    that needs to be tested into the table.
#
# 3. On master, read each ALTER TABLE command from the table in a loop.
#    Execute each of this command along with some transactions that can be applied
#    in parallel, by setting same commit parent for all the transactions.
#
# 4. Source extra/rpl_tests/rpl_mts_replica_preserve_commit_order_nobinlog.inc to verify
#    the ordering of commits on slave.
#
# 5. Cleanup
#
# === References ===
#
# Bug#30483615 : ADD TESTS TO VERIFY IF SPCO IS PRESERVED FOR ALTER TABLE VARIANT COMMANDS
# WL7846 : MTS: replica-preserve-commit-order when log-replica-updates/binlog is disabled

--let $rpl_gtid_utils = 1
--let $rpl_skip_start_slave = 1
--source include/master-slave.inc

# Starts slave with 8 worker threads
--let $mts_replica_parallel_workers= 8
--let $mts_num_preceding_trans= 5
--let $mts_spco_save_gtid_executed = 1
--let $mts_spco_check_gtid_executed_before_rollback = 0

# Set Up
--source include/rpl_connection_slave.inc
CALL mtr.add_suppression("You need to use --log-bin to make --binlog-format work");
CALL mtr.add_suppression("The transaction owned GTID is already in the gtid_executed table");

SET @save_replica_parallel_workers= @@global.replica_parallel_workers;
SET @save_replica_parallel_type= @@global.replica_parallel_type;
SET @save_replica_preserve_commit_order= @@global.replica_preserve_commit_order;
SET GLOBAL replica_parallel_type = 'LOGICAL_CLOCK';
--eval SET GLOBAL replica_parallel_workers= $mts_replica_parallel_workers
SET GLOBAL replica_preserve_commit_order= ON;
--source include/start_slave.inc

--source include/rpl_connection_master1.inc

SET @save_binlog_transaction_dependency_tracking= @@global.binlog_transaction_dependency_tracking;
SET @@global.binlog_transaction_dependency_tracking = COMMIT_ORDER;

# Create tables on master
CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE = InnoDB;
CREATE TABLE t2 (c1 INT PRIMARY KEY) ENGINE = InnoDB;

# Create table to load commands
CREATE TABLE commands (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(100));

# Load commands into table
LOAD DATA INFILE '../../std_data/alter_table.csv' INTO TABLE commands(b);

--source include/sync_slave_sql_with_master.inc

--let $counter = `SELECT COUNT(*) COUNT FROM commands`
--let $j =1

while($j <= $counter)
{

--let $mts_spco_command = `SELECT b FROM commands WHERE a='$j'`

--echo
--echo # Check for $mts_spco_command

--let $mts_spco_skip_init_statement = 1
--let $mts_spco_start_statement =

--let $mts_spco_block_statement = BEGIN; INSERT INTO t1 VALUES (1);

--let $mts_spco_parallel_statement1 = `SELECT CONCAT ('BEGIN; INSERT INTO t1 VALUES (1); COMMIT; BEGIN; INSERT INTO t1 VALUES (2); COMMIT; ', '$mts_spco_command')`
--let $mts_spco_parallel_statement2 = BEGIN; INSERT INTO t1 VALUES (5); COMMIT; BEGIN; INSERT INTO t1 VALUES (6); COMMIT; BEGIN; INSERT INTO t1 VALUES (7); COMMIT;

--let $mts_spco_assert_text1 = Verify table t1 is empty
--let $mts_spco_assert_cond1 = "[SELECT count(*) COUNT FROM t1, COUNT, 1]" = "0"

--let $mts_spco_assert_text2 = Verify table t2 is empty
--let $mts_spco_assert_cond2 = "[SELECT count(*) COUNT FROM t2, COUNT, 1]" = "0"

--let $mts_spco_rollback_statement = ROLLBACK;
--let $mts_spco_end_statement = TRUNCATE TABLE t1; TRUNCATE TABLE t2;
--let $mts_spco_cleanup_statement = 0

--source extra/rpl_tests/rpl_mts_replica_preserve_commit_order_nobinlog.inc
--inc $j
}

--echo
--echo # Cleanup
--echo

--source include/rpl_connection_master1.inc
SET GLOBAL binlog_transaction_dependency_tracking=@save_binlog_transaction_dependency_tracking;
DROP TABLE t1,t2,commands;

--source include/sync_slave_sql_with_master.inc

--source include/stop_slave.inc

SET GLOBAL replica_parallel_type=@save_replica_parallel_type;
--disable_warnings
SET GLOBAL replica_parallel_workers=@save_replica_parallel_workers;
--enable_warnings
SET GLOBAL replica_preserve_commit_order=@save_replica_preserve_commit_order;
--source include/start_slave.inc

--source include/rpl_end.inc