Debian Codegraph @

mysql-test/suite/binlog/t/binlog_commit_fail.test

raw
1 # Tests of commit time failures.
2 # At committing of an auto-commit statement a failure to commit in its
3 # binlog branch should rollback at least the transactional part of the statement.
4 #
5 # References:
6 # MDEV-35506 commit policy of one-phase-commit even at errored-out binlogging leads to assert
7 # MDEV-36027 Errored-out CREATE-SELECT does not binlog results of non-transactional table modification
8
9 source include/have_innodb.inc;
10 source include/have_binlog_format_row.inc;
11
12 set @@session.gtid_domain_id=1;
13 set @save_gtid_stric_mode=@@global.gtid_strict_mode;
14
15 create table ta (a int) engine=aria;
16 create table ti (a int) engine=innodb;
17 create table ti_pk (a int primary key) engine=innodb;
18 create table t (a int) engine=innodb;
19 delimiter |;
20 create function f_i()
21 returns integer
22 begin
23 insert into ti set a=1;
24 return 1;
25 end |
26 create function f_ia(arg int)
27 returns integer
28 begin
29 insert into ti_pk set a=1;
30 insert into ta set a=1;
31 insert into ti_pk set a=arg;
32 return 1;
33 end |
34 delimiter ;|
35
36 call mtr.add_suppression("Error writing file");
37
38 # Naturally all empty now
39 select count(*) as zero from t;
40 select count(*) as zero from ta;
41 select count(*) as zero from ti;
42
43 # Force manual value assignement to gtid::seq_no while in the strict mode
44 # so that the value is rejected. Despite the errorred out statement
45 # being at its commit phase it will eventually be rolled back.
46 # Side effects of non-transactional engines, like Aria, are displayed.
47 --echo # 1. simple Innodb test
48 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
49 set @@global.gtid_strict_mode=1;
50 # mask possible allowed seq_no shift
51 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
52 --error ER_GTID_STRICT_OUT_OF_ORDER
53 insert into t set a=1;
54
55 --echo # observe effective rollback
56 select count(*) as zero from t;
57
58 --echo # 2. simple Aira test
59 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
60 set @@global.gtid_strict_mode=1;
61 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
62 --error ER_GTID_STRICT_OUT_OF_ORDER
63 insert into ta values (1),(2);
64
65 --echo # note no rollback
66 select count(*) as '*NON-zero*' from ta;
67 # local cleanup
68 delete from ta;
69
70 --echo # 3. multi-engine test
71 # A. non-transactional top-level
72 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
73 set @@global.gtid_strict_mode=1;
74 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
75 --error ER_GTID_STRICT_OUT_OF_ORDER
76 insert into ta set a=f_i();
77 --echo # note no rollback..
78 select count(*) as one from ta;
79 --echo # ..except transactional engine
80 select count(*) as zero from ti;
81 delete from ta;
82
83 # B. non-transactional in the leaf
84 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
85 set @@global.gtid_strict_mode=1;
86 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
87 --error ER_GTID_STRICT_OUT_OF_ORDER
88 insert into t set a=f_ia(0);
89
90 --echo # note no rollback..
91 select count(*) as one from ta;
92 --echo # ..except transactional engine
93 select count(*) as zero from t;
94 select count(*) as zero from ti_pk;
95 delete from ta;
96
97 --echo # 4. create-table-select-f()
98 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
99 --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
100 # A. two phase commit branch
101 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
102 set @@global.gtid_strict_mode=1;
103 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
104 --error ER_GTID_STRICT_OUT_OF_ORDER
105 create table f_x (a int) select f_i() as a;
106 --echo # rollback indeed takes place in the pure transactional case
107 select count(*) as zero from ti;
108
109 # B. one phase commit branch
110 --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
111 --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
112 set @@global.gtid_strict_mode=0; set @@session.gtid_seq_no=1;
113 set @@global.gtid_strict_mode=1;
114 --replace_regex /GTID 1-1-[0-9]+/GTID VALUE/
115 --error ER_GTID_STRICT_OUT_OF_ORDER
116 create table t_x (a int) engine=aria select f_ia(0) as a;
117 --error ER_NO_SUCH_TABLE
118 select * from t_x;
119
120 --echo # **TODO**: fix MDEV-36027
121 --echo # **TODO**: the empty binlog is buggy ..
122 --source include/show_binlog_events.inc
123 --echo # .. as non-transactional `ta` (and `t_x` sic!) are modified
124 select count(*) as one from ta;
125 select count(*) as zero from ti;
126
127 delete from ta;
128 --echo #.
129
130 # cleanup
131
132 set @@global.gtid_strict_mode=@save_gtid_stric_mode;
133 drop function f_i;
134 drop function f_ia;
135 drop table t, ta, ti, ti_pk;