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 91 92 93 94 95 96 97
|
#
# Test that rows in ndb_binlog_index referencing binlog files
# which does not exists are removed when MySQL Server starts.
#
# 1. Add rows to create references ten different binlog files
# 2. Save copies of rows for the three first binlog files
# 3. Purge first five binlog files
# 4. Restore to three saved rows
# 5. Add rows NOT referencing any binlog files, these rows
# are identified by 'File' column containing the text "Test"
# 6. Restart the MySQL Server
# 7. Wait until there are only the expected number of rows in ndb_binlog_index
# 8. Show the expected rows.
#
-- source include/have_ndb.inc
-- source include/have_binlog_format_mixed_or_row.inc
# Ignore the warning generated by ndbcluster's binlog thread
# when mysqld is restarted
--disable_query_log ONCE
call mtr.add_suppression("mysqld startup An incident event has been written");
# Binlogging must be on
SHOW VARIABLES LIKE 'log_bin';
SHOW VARIABLES LIKE 'ndb_log_bin';
RESET MASTER;
--echo # Find physical binlog file name format as it varies between platforms
CREATE TABLE check_binlog_name (a int primary key) engine = NDB;
INSERT INTO check_binlog_name VALUES (1);
DROP TABLE check_binlog_name;
let $binlog_name =
`SELECT SUBSTRING(File, 1, LENGTH(File)-LENGTH('.000001'))
FROM mysql.ndb_binlog_index ORDER BY epoch LIMIT 1`;
#echo binlog_name: $binlog_name;
RESET MASTER;
--echo # 1. Insert to create referencing rows
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=ndb;
let $i = 1;
let $files = 10;
while ($i <= $files)
{
eval INSERT INTO t1 VALUES ($i);
# Rotate to new binlog file
FLUSH LOGS;
inc $i;
}
DROP TABLE t1;
--echo # 2. Save copies of the three first rows
CREATE TEMPORARY TABLE save_rows_from_binlog_index AS
SELECT * FROM mysql.ndb_binlog_index ORDER BY epoch LIMIT 3;
--echo # 3. Purge first five binlog files
PURGE BINARY LOGS TO 'binlog.000006';
--echo # 4. Restore saved rows, these should be removed during restart
INSERT INTO mysql.ndb_binlog_index SELECT * FROM save_rows_from_binlog_index;
--echo # 5. Insert rows which will be removed
insert into mysql.ndb_binlog_index values
(9, 'Test.000001', 20, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, 'Test.000001', 21, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, 'Test.000001', 22, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, './Test.000002', 23, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, './Test.000002', 24, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, '/home/a/b/c/d/e/f/Test.000004', 25, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, 'c:\\Progra~1\\WinAmp\\Skins\\Test.000005', 26, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'),
(9, './Test.000006/', 27, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file');
--source include/show_binary_logs.inc
--replace_result $binlog_name binlog
SELECT DISTINCT(File) FROM mysql.ndb_binlog_index;
--echo # 6. Restart
let $mysqld_name=mysqld.1.1;
--source include/restart_mysqld.inc
--source include/ndb_not_readonly.inc
--echo # 7. Wait for 5 rows
let $wait_condition=
SELECT COUNT(File) = 5 FROM mysql.ndb_binlog_index;
--source include/wait_condition.inc
--echo # 8. Show that referenced rows are still there
--replace_result $binlog_name binlog
SELECT DISTINCT(File) FROM mysql.ndb_binlog_index;
RESET MASTER;
|