Debian Codegraph @

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

raw
1 # Prove basic properties of
2 #
3 # FLUSH BINARY LOGS DELETE_DOMAIN_ID = (...)
4 #
5 # The command removes the supplied list of domains from the current
6 # @@global.gtid_binlog_state provided the binlog files do not contain
7 # events from such domains.
8
9 # The test is not format specific. One format is chosen to run it.
10 --source include/have_binlog_format_mixed.inc
11
12 # Reset binlog state
13 RESET MASTER;
14
15 # Empty list is accepted
16 FLUSH BINARY LOGS DELETE_DOMAIN_ID = ();
17 --echo and the command execution is effective thence rotates binlog as usual
18 --source include/show_binary_logs.inc
19
20 --echo Non-existed domain is warned, the command completes without rotation
21 --echo but with a warning
22 --let $binlog_pre_flush=query_get_value(SHOW MASTER STATUS, Position, 1)
23 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (99);
24 --source include/show_binary_logs.inc
25
26 # Log one event in a specified domain and try to delete the domain
27 SET @@SESSION.gtid_domain_id=1;
28 SET @@SESSION.server_id=1;
29 CREATE TABLE t (a int);
30 SELECT @@GLOBAL.gtid_binlog_state, @@GLOBAL.gtid_binlog_pos;
31 --let $binlog_start=
32 --source include/show_binlog_events.inc
33
34 --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
35 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
36
37 # the same error after log rotation
38 FLUSH BINARY LOGS;
39 --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
40 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
41
42 # the latest binlog does not really contain any events incl ones from 1-domain
43 --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
44 --eval PURGE BINARY LOGS TO '$purge_to_binlog';
45 # So now it's safe to delete
46 --error 0
47 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
48 --echo Gtid_list of the current binlog does not contain '1':
49 --let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1)
50 --source include/show_gtid_list.inc
51 --echo But the previous log's Gtid_list may have it which explains a warning from the following command
52 --let $binlog_file=$purge_to_binlog
53 --source include/show_gtid_list.inc
54
55 --echo Already deleted domain in Gtid_list of the earliest log is benign
56 --echo but may cause a warning
57 --error 0
58 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
59
60 # Few domains delete. The chosen number verifies among others how
61 # expected overrun of the static buffers of underlying dynamic arrays is doing.
62 --let $domain_cnt=17
63 --let $server_in_domain_cnt=3
64 --let $err_domain_id=`SELECT FLOOR($domain_cnt/2)`
65 --let $err_server_id=`SELECT FLOOR($server_in_domain_cnt/2)`
66 --let $domain_list=
67 --disable_query_log
68 while ($domain_cnt)
69 {
70 --let servers=$server_in_domain_cnt
71 --eval SET @@SESSION.gtid_domain_id=$domain_cnt
72 while ($servers)
73 {
74 --eval SET @@SESSION.server_id=10*$domain_cnt + $servers
75 --eval INSERT INTO t SET a=@@SESSION.server_id
76
77 --dec $servers
78 }
79 --let $domain_list= $domain_cnt, $domain_list
80
81 --dec $domain_cnt
82 }
83 --enable_query_log
84 --let $zero=0
85 --let $domain_list= $domain_list$zero
86
87 --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
88 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list)
89
90 --echo MDEV-31140: Missing error from DELETE_DOMAIN_ID when gtid_binlog_state partially matches GTID_LIST.
91 FLUSH BINARY LOGS;
92 --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
93 --eval PURGE BINARY LOGS TO '$purge_to_binlog'
94 --source include/show_binary_logs.inc
95 --eval SET @@SESSION.gtid_domain_id=$err_domain_id
96 --eval SET @@SESSION.server_id=10*$err_domain_id + $err_server_id
97 eval INSERT INTO t SELECT 1+MAX(a) FROM t;
98 --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
99 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list)
100
101 # Now satisfy the safety condtion to purge log files containing $domain list
102 FLUSH BINARY LOGS;
103 --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
104 --eval PURGE BINARY LOGS TO '$purge_to_binlog'
105 --error 0
106 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list)
107 --echo Gtid_list of the current binlog does not contain $domain_list:
108 --let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1)
109 --source include/show_gtid_list.inc
110
111 # Show reaction on @@global.gtid_binlog_state not succeeding
112 # earlier state as described by the 1st binlog' Gtid_list.
113 # Now let it be out-order gtid logged to a domain unrelated to deletion.
114
115 --let $del_d_id=1
116 --eval SET @@SESSION.gtid_domain_id=$del_d_id;
117 SET @@SESSION.server_id=1;
118 SET @@SESSION.gtid_seq_no=1;
119 INSERT INTO t SET a=1;
120 SET @@SESSION.server_id=2;
121 SET @@SESSION.gtid_seq_no=2;
122 INSERT INTO t SET a=2;
123
124 SET @@SESSION.gtid_domain_id=11;
125 SET @@SESSION.server_id=11;
126 SET @@SESSION.gtid_seq_no=11;
127 INSERT INTO t SET a=11;
128
129 SET @gtid_binlog_state_saved=@@GLOBAL.gtid_binlog_state;
130 FLUSH BINARY LOGS;
131
132 # Inject out of order for domain '11' before
133 SET @@SESSION.gtid_domain_id=11;
134 SET @@SESSION.server_id=11;
135 SET @@SESSION.gtid_seq_no=1;
136 INSERT INTO t SET a=1;
137
138 SELECT @gtid_binlog_state_saved "as original state", @@GLOBAL.gtid_binlog_state as "out of order for 11 domain state";
139
140 # to delete '1', first to purge logs containing its events
141 --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
142 --eval PURGE BINARY LOGS TO '$purge_to_binlog'
143
144 --echo the following command succeeds with warnings
145 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($del_d_id)
146
147 # cleanup: forget the out-of-order
148 RESET MASTER;
149
150 #
151 # MDEV-14431
152 # Check rejection to delete a domain with value exceeding its range's maximum
153 #
154 --let $d_max_plus_1=`SELECT 1 << 32`
155 --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
156 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($d_max_plus_1)
157
158 # accepted maximum:
159 --let $d_max=`SELECT (1 << 32) - 1`
160 --error 0
161 --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($d_max)
162
163 #
164 # MDEV-37885
165 # Server crash or ASAN errors in rpl_binlog_state::drop_domain
166 #
167 RESET MASTER;
168 SET @@GLOBAL.gtid_domain_id=0;
169 SET @@SESSION.gtid_domain_id=0;
170 CREATE USER u;
171 FLUSH BINARY LOGS;
172 --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
173 --eval PURGE BINARY LOGS TO '$purge_to_binlog'
174 --error 0
175 FLUSH BINARY LOGS DELETE_DOMAIN_ID = (0), BINARY LOGS DELETE_DOMAIN_ID = (0);
176 DROP USER u;
177
178
179 #
180 # Cleanup
181 #
182
183 DROP TABLE t;
184 RESET MASTER;