File: ndb_binlog_purge_lock.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (90 lines) | stat: -rw-r--r-- 3,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
First initialize the binlog
reset master;
DROP TABLE IF EXISTS t1;
Test that binlog purging doesn't use table lock on ndb_binlog_index
Put some real stuff in the Binlog.
create table test.t1 (
pk integer primary key auto_increment,
a varchar(1000)
) engine=ndb;
insert into test.t1 values (NULL, repeat('BJC', 300));
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
insert into test.t1 select NULL, a from test.t1;
select trim(trailing "binlog.000001" from File)
from mysql.ndb_binlog_index
where epoch in (select max(epoch) from mysql.ndb_binlog_index)
into @file_prefix;
select concat(@file_prefix, "binlog.000001") into @file1;
Have at least 100 epoch rows
select count(*)/100 > 0 from mysql.ndb_binlog_index where File=@file1;
count(*)/100 > 0
1
Flush log to get onto the next file...
FLUSH LOGS;
select concat(@file_prefix, "binlog.000002") into @file2;
create table test.files(file1 varchar(255), file2 varchar(255));
insert into test.files values(@file1, @file2);
Pick one row from ndb_binlog_index
CREATE TEMPORARY TABLE my_ndb_binlog_index (
epoch BIGINT UNSIGNED NOT NULL,
orig_server_id INT UNSIGNED NOT NULL,
orig_epoch BIGINT UNSIGNED NOT NULL
);
insert into my_ndb_binlog_index
select epoch, orig_server_id, orig_epoch
from mysql.ndb_binlog_index
where File=@file1 limit 1;
select epoch from my_ndb_binlog_index into @epoch;
select orig_server_id from my_ndb_binlog_index into @orig_server_id;
select orig_epoch from my_ndb_binlog_index into @orig_epoch;
Lock one row to block purge
start transaction;
select count(1) from mysql.ndb_binlog_index
where epoch = @epoch and
orig_server_id = @orig_server_id and
orig_epoch = @orig_epoch and
File=@file1 for update;
count(1)
1
Check that there are no rows in the next file
select count(*)=0 from mysql.ndb_binlog_index where File=@file2;
count(*)=0
1
Start the purge that will get stuck on one row
PURGE BINARY LOGS TO 'binlog.000002';
Wait 10 sec for purge to run into the row lock
Now we should still have some rows in the first file (since the purge is stuck)
select count(*)>0 from mysql.ndb_binlog_index where File=@file1;
count(*)>0
1
Insert some more rows
insert into test.t1 select NULL, a from test.t1;
Wait for rows to be committed to binlog
Now we see rows in the next file (which means there is no table lock)
select count(*)>0 from mysql.ndb_binlog_index where File=@file2;
count(*)>0
1
Release the purge
commit;
Purge done
Now we should have no rows in the first file
select count(*)=0 from mysql.ndb_binlog_index where File=@file1 into @result;
select @result;
@result
1
Now we still should see rows in the next file
select count(*)>0 from mysql.ndb_binlog_index where File=@file2;
count(*)>0
1
cleanup
drop table test.t1, test.files;
Done