Debian Codegraph @

mysql-test/suite/rpl/t/rpl_writeset_add_unique_key.test

raw
1 # ==== Purpose ====
2 #
3 # This test verifies that when binlog_row_image=minimum and a table has
4 # both unique + primary key then there should not be any conflict running
5 # the transactions on this table on the soure and replica.
6 #
7 # ==== Requirements ====
8 # R1. In case of binlog_row_image=minimum, when generating read_sets and
9 # writesets, we should include unique key also such that transaction dependencies
10 # are calculated correctly and transactions do not fail on replica while running
11 # in parallel.
12 #
13 # ==== Implementation ====
14 #
15 # 1) Create source-replica topology.
16 # 2) Save current variables on Source.
17 # 2.1) Save current binlog_row_image.
18 # 2.2) Save current tracking mode.
19 # 3) Setup neccesary varibales on source.
20 # 3.1) Set the binlog_row_image=MINIMAL.
21 # 3.2) Set the global BINLOG_TRANSACTION_DEPENDENCY_TRACKING=WRITESET.
22 # 4) Create table and procedure on source.
23 # 5) Switch to source and call procedure.
24 # 6) Clear system variables on source.
25 # 7) Cleanup.
26 #
27 # ==== References ====
28 #
29 # Bug#31636339 MTS IS UNUSABLE; ERRNO 3030, AND WORKER HA_ERR_FOUND_DUPP_KEY OR HA_ERR_LOCK_WAIT_TIMEOUT
30 #
31 --source include/have_binlog_format_row.inc
32 --source include/only_mts_replica_parallel_workers.inc
33 --let $option_name = replica_transaction_retries
34 --let $option_operator = >
35 --let $option_value = 2
36 --source include/only_with_option.inc
37 --let $skip_configuration_privilege_checks_user= 'skip'
38 --let $rpl_privilege_checks_user_grant_all= 1
39 --echo #
40 --echo # 1. Create source-replica topology.
41 --source include/master-slave.inc
42
43 --echo
44 --echo # 2. Save the current variables on source.
45 --echo # 2.1 Save current binlog_row_image.
46 SET @old_binlog_row_image= @@binlog_row_image;
47
48 # 2.2 Save current tracking mode.
49 --let $old_trx_tracker = `SELECT @@GLOBAL.BINLOG_TRANSACTION_DEPENDENCY_TRACKING`
50
51 --echo #
52 --echo # 3. Setup neccsary variables on source.
53 --echo # 3.1 Set the binlog_row_image=MINIMAL.
54 SET @@session.binlog_row_image = 'MINIMAL';
55
56 # 3.2 Set the global BINLOG_TRANSACTION_DEPENDENCY_TRACKING=WRITESET.
57 SET GLOBAL BINLOG_TRANSACTION_DEPENDENCY_TRACKING = WRITESET;
58
59 --echo #
60 --echo # 4.Create table and procedure on source.
61 CREATE TABLE t( a tinyint unsigned primary key, b tinyint, c int, d bigint,
62 f char(10), g char(255), h text, i longtext, unique key(g,f),
63 unique key(f,c), key(c,d,b), key(i(10),f(10),b)) ENGINE=InnoDB;
64
65 drop procedure if exists p;
66 delimiter |;
67 create procedure p(p_i bigint)
68 begin
69 declare v_i bigint default 0;
70 repeat
71 replace into t values(
72 floor(rand()*5),floor(rand()*5),floor(rand()*5),floor(rand()*5),
73 floor(rand()*5),floor(rand()*5),floor(rand()*5),floor(rand()*5)
74 ),
75 (
76 floor(rand()*5),floor(rand()*5),floor(rand()*5),floor(rand()*5),
77 floor(rand()*5),floor(rand()*5),floor(rand()*5),floor(rand()*5)
78 );
79 set v_i=v_i+1;
80 until v_i > p_i end repeat;
81 end|
82 delimiter ;|
83
84 --echo #
85 --echo #
86 --echo # 5. Switch to source and call procedure.
87 --source include/rpl_connection_master.inc
88 call p(1000);
89
90 --source include/sync_slave_sql_with_master.inc
91
92 --echo #
93 --echo # 6. Clear system variables on source.
94 --echo #
95 --source include/rpl_connection_master.inc
96 SET SESSION binlog_row_image= @old_binlog_row_image;
97 --replace_result $old_trx_tracker OLD_TRX_TRACKER
98 --eval SET GLOBAL BINLOG_TRANSACTION_DEPENDENCY_TRACKING = $old_trx_tracker
99
100 # Supress the error warning on replica.
101 --source include/rpl_connection_slave.inc
102 CALL mtr.add_suppression("Worker .* failed executing transaction.*");
103
104 # 7. Cleanup.
105 --source include/rpl_connection_master.inc
106 DROP TABLE t;
107 DROP PROCEDURE p;
108 --source include/rpl_end.inc
109