Debian Codegraph @

mysql-test/suite/ndb_binlog/r/ndb_binlog_purge_lock.result

raw
1 First initialize the binlog
2 reset master;
3 DROP TABLE IF EXISTS t1;
4 Test that binlog purging doesn't use table lock on ndb_binlog_index
5 Put some real stuff in the Binlog.
6 create table test.t1 (
7 pk integer primary key auto_increment,
8 a varchar(1000)
9 ) engine=ndb;
10 insert into test.t1 values (NULL, repeat('BJC', 300));
11 insert into test.t1 select NULL, a from test.t1;
12 insert into test.t1 select NULL, a from test.t1;
13 insert into test.t1 select NULL, a from test.t1;
14 insert into test.t1 select NULL, a from test.t1;
15 insert into test.t1 select NULL, a from test.t1;
16 insert into test.t1 select NULL, a from test.t1;
17 insert into test.t1 select NULL, a from test.t1;
18 insert into test.t1 select NULL, a from test.t1;
19 insert into test.t1 select NULL, a from test.t1;
20 insert into test.t1 select NULL, a from test.t1;
21 insert into test.t1 select NULL, a from test.t1;
22 select trim(trailing "binlog.000001" from File)
23 from mysql.ndb_binlog_index
24 where epoch in (select max(epoch) from mysql.ndb_binlog_index)
25 into @file_prefix;
26 select concat(@file_prefix, "binlog.000001") into @file1;
27 Have at least 100 epoch rows
28 select count(*)/100 > 0 from mysql.ndb_binlog_index where File=@file1;
29 count(*)/100 > 0
30 1
31 Flush log to get onto the next file...
32 FLUSH LOGS;
33 select concat(@file_prefix, "binlog.000002") into @file2;
34 create table test.files(file1 varchar(255), file2 varchar(255));
35 insert into test.files values(@file1, @file2);
36 Pick one row from ndb_binlog_index
37 CREATE TEMPORARY TABLE my_ndb_binlog_index (
38 epoch BIGINT UNSIGNED NOT NULL,
39 orig_server_id INT UNSIGNED NOT NULL,
40 orig_epoch BIGINT UNSIGNED NOT NULL
41 );
42 insert into my_ndb_binlog_index
43 select epoch, orig_server_id, orig_epoch
44 from mysql.ndb_binlog_index
45 where File=@file1 limit 1;
46 select epoch from my_ndb_binlog_index into @epoch;
47 select orig_server_id from my_ndb_binlog_index into @orig_server_id;
48 select orig_epoch from my_ndb_binlog_index into @orig_epoch;
49 Lock one row to block purge
50 start transaction;
51 select count(1) from mysql.ndb_binlog_index
52 where epoch = @epoch and
53 orig_server_id = @orig_server_id and
54 orig_epoch = @orig_epoch and
55 File=@file1 for update;
56 count(1)
57 1
58 Check that there are no rows in the next file
59 select count(*)=0 from mysql.ndb_binlog_index where File=@file2;
60 count(*)=0
61 1
62 Start the purge that will get stuck on one row
63 PURGE BINARY LOGS TO 'binlog.000002';
64 Wait 10 sec for purge to run into the row lock
65 Now we should still have some rows in the first file (since the purge is stuck)
66 select count(*)>0 from mysql.ndb_binlog_index where File=@file1;
67 count(*)>0
68 1
69 Insert some more rows
70 insert into test.t1 select NULL, a from test.t1;
71 Wait for rows to be committed to binlog
72 Now we see rows in the next file (which means there is no table lock)
73 select count(*)>0 from mysql.ndb_binlog_index where File=@file2;
74 count(*)>0
75 1
76 Release the purge
77 commit;
78 Purge done
79 Now we should have no rows in the first file
80 select count(*)=0 from mysql.ndb_binlog_index where File=@file1 into @result;
81 select @result;
82 @result
83 1
84 Now we still should see rows in the next file
85 select count(*)>0 from mysql.ndb_binlog_index where File=@file2;
86 count(*)>0
87 1
88 cleanup
89 drop table test.t1, test.files;
90 Done