Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_mts_spco_alter_table_analyze_partition.test

raw
1 # ==== Purpose ====
2 #
3 # Verifies that ALTER TABLE .. ANALYZE PARTITION is maintaining commit order.
4 #
5 # ==== Implementation ====
6 #
7 # 1. We start replica (server2) with replica_preserve_commit_order enabled
8 # and running with 2 applier workers.
9 #
10 # 2. On slave, we add the same first insert statement which will be applied on
11 # master in step 3, but we do not commit it, to take a lock on row and block
12 # slave sql thread when transaction are applied on master in step 3.
13 #
14 # 3. The master generates some transactions which can be applied in parallel,
15 # by setting same commit parents for all the inserts.
16 #
17 # 4. On slave, we verify that all the other inserts are also blocked and waiting
18 # for first insert to commit i.e. applier threads are in stage 'Waiting for
19 # preceding transaction to commit' and their is no data in the table. We also
20 # save value of @@GLOBAL.GTID_EXECUTED.
21 #
22 # 5. On slave, we rollback the first insert executed in step 2. We again save
23 # value of @@GLOBAL.GTID_EXECUTED before rollback.
24 #
25 # 6. On slave, we verify no additional transaction is added after first
26 # insert was blocked i.e. ALTER TABLE .. ANALYZE PARTITION is not
27 # bypassing commit order. We verify this by checking value of
28 # @@GLOBAL.GTID_EXECUTED saved in step 4 and step5 is same.
29 #
30 # 7. Cleanup.
31
32 --source include/have_debug.inc
33 --source include/have_debug_sync.inc
34
35 --let $rpl_skip_start_slave = 1
36 --source include/master-slave.inc
37
38 --source include/rpl_connection_slave.inc
39 --source include/gtid_utils.inc
40
41
42 --source include/rpl_connection_master.inc
43 --let $mts_replica_parallel_workers= 8
44 --let $mts_num_preceding_trans= 6
45
46 --let $mts_spco_save_gtid_executed = 1
47 --let $mts_spco_check_gtid_executed_before_rollback = 0
48
49 --let $mts_spco_start_statement = CREATE TABLE t1(a INT PRIMARY KEY); CREATE TABLE t2 (i INTEGER) PARTITION BY RANGE(i) PARTITIONS 2 SUBPARTITION BY HASH(i) (PARTITION p0 VALUES LESS THAN(100) (SUBPARTITION sp00, SUBPARTITION sp01), PARTITION p1 VALUES LESS THAN(200) (SUBPARTITION sp10, SUBPARTITION sp11));
50
51 --let $mts_spco_block_statement = BEGIN; INSERT INTO t1 VALUES (1);
52
53 --let $mts_spco_parallel_statement1 = BEGIN; INSERT INTO t1 VALUES (1); COMMIT; BEGIN; INSERT INTO t1 VALUES (2); COMMIT; ALTER TABLE t2 ANALYZE PARTITION p0; BEGIN; INSERT INTO t1 VALUES (4); COMMIT;
54 --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;
55
56 --let $mts_spco_assert_text1 = Verify table t1 is empty
57 --let $mts_spco_assert_cond1 = "[SELECT count(*) COUNT FROM t1, COUNT, 1]" = "0"
58
59 --let $mts_spco_save_gtid_executed= 1
60 --let $mts_spco_rollback_statement = ROLLBACK;
61 --source extra/rpl_tests/rpl_mts_replica_preserve_commit_order_nobinlog.inc
62
63
64 --echo
65 --echo # On slave, verify no additional transaction is added after first
66 --echo # insert was blocked i.e. ALTER TABLE .. ANALYZE PARTITION is not
67 --echo # bypassing commit order.
68 --echo
69
70 --let $is_gtid_equal=`SELECT GTID_IS_EQUAL('$gtid_executed_internal_val1', '$gtid_executed_internal_val2') != 0`
71
72 --let $assert_cond= $is_gtid_equal = 1
73 --let $assert_text= No additional transaction is added on slave after first insert was blocked
74 --source include/assert.inc
75
76
77 --echo
78 --echo # Cleanup
79 --echo
80
81 --source include/rpl_connection_master.inc
82
83 DROP TABLE t1;
84 DROP TABLE t2;
85
86 SET GLOBAL binlog_transaction_dependency_tracking=@save_binlog_transaction_dependency_tracking;
87
88 --source include/sync_slave_sql_with_master.inc
89 --source include/stop_slave.inc
90
91 SET GLOBAL replica_parallel_type= @save_replica_parallel_type;
92 --disable_warnings
93 SET GLOBAL replica_parallel_workers= @save_replica_parallel_workers;
94 --enable_warnings
95 SET GLOBAL replica_preserve_commit_order= @save_replica_preserve_commit_order;
96 --source include/start_slave.inc
97
98 --source include/gtid_utils_end.inc
99 --source include/rpl_end.inc