| 1 |
# |
| 2 |
# Test that rows in ndb_binlog_index referencing binlog files |
| 3 |
# which does not exists are removed when MySQL Server starts. |
| 4 |
# |
| 5 |
# 1. Add rows to create references ten different binlog files |
| 6 |
# 2. Save copies of rows for the three first binlog files |
| 7 |
# 3. Purge first five binlog files |
| 8 |
# 4. Restore to three saved rows |
| 9 |
# 5. Add rows NOT referencing any binlog files, these rows |
| 10 |
# are identified by 'File' column containing the text "Test" |
| 11 |
# 6. Restart the MySQL Server |
| 12 |
# 7. Wait until there are only the expected number of rows in ndb_binlog_index |
| 13 |
# 8. Show the expected rows. |
| 14 |
# |
| 15 |
|
| 16 |
-- source include/have_ndb.inc |
| 17 |
-- source include/have_binlog_format_mixed_or_row.inc |
| 18 |
|
| 19 |
# Ignore the warning generated by ndbcluster's binlog thread |
| 20 |
# when mysqld is restarted |
| 21 |
--disable_query_log ONCE |
| 22 |
call mtr.add_suppression("mysqld startup An incident event has been written"); |
| 23 |
|
| 24 |
# Binlogging must be on |
| 25 |
SHOW VARIABLES LIKE 'log_bin'; |
| 26 |
SHOW VARIABLES LIKE 'ndb_log_bin'; |
| 27 |
|
| 28 |
RESET MASTER; |
| 29 |
|
| 30 |
--echo # Find physical binlog file name format as it varies between platforms |
| 31 |
CREATE TABLE check_binlog_name (a int primary key) engine = NDB; |
| 32 |
INSERT INTO check_binlog_name VALUES (1); |
| 33 |
DROP TABLE check_binlog_name; |
| 34 |
let $binlog_name = |
| 35 |
`SELECT SUBSTRING(File, 1, LENGTH(File)-LENGTH('.000001')) |
| 36 |
FROM mysql.ndb_binlog_index ORDER BY epoch LIMIT 1`; |
| 37 |
#echo binlog_name: $binlog_name; |
| 38 |
|
| 39 |
RESET MASTER; |
| 40 |
|
| 41 |
--echo # 1. Insert to create referencing rows |
| 42 |
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=ndb; |
| 43 |
let $i = 1; |
| 44 |
let $files = 10; |
| 45 |
while ($i <= $files) |
| 46 |
{ |
| 47 |
eval INSERT INTO t1 VALUES ($i); |
| 48 |
# Rotate to new binlog file |
| 49 |
FLUSH LOGS; |
| 50 |
inc $i; |
| 51 |
} |
| 52 |
DROP TABLE t1; |
| 53 |
|
| 54 |
--echo # 2. Save copies of the three first rows |
| 55 |
CREATE TEMPORARY TABLE save_rows_from_binlog_index AS |
| 56 |
SELECT * FROM mysql.ndb_binlog_index ORDER BY epoch LIMIT 3; |
| 57 |
|
| 58 |
--echo # 3. Purge first five binlog files |
| 59 |
PURGE BINARY LOGS TO 'binlog.000006'; |
| 60 |
|
| 61 |
--echo # 4. Restore saved rows, these should be removed during restart |
| 62 |
INSERT INTO mysql.ndb_binlog_index SELECT * FROM save_rows_from_binlog_index; |
| 63 |
|
| 64 |
--echo # 5. Insert rows which will be removed |
| 65 |
insert into mysql.ndb_binlog_index values |
| 66 |
(9, 'Test.000001', 20, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 67 |
(9, 'Test.000001', 21, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 68 |
(9, 'Test.000001', 22, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 69 |
|
| 70 |
(9, './Test.000002', 23, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 71 |
(9, './Test.000002', 24, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 72 |
|
| 73 |
(9, '/home/a/b/c/d/e/f/Test.000004', 25, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 74 |
(9, 'c:\\Progra~1\\WinAmp\\Skins\\Test.000005', 26, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'), |
| 75 |
|
| 76 |
(9, './Test.000006/', 27, 0, 0, 0, 0, 0, 0, 0, 0, 'Next file'); |
| 77 |
|
| 78 |
--source include/show_binary_logs.inc |
| 79 |
--replace_result $binlog_name binlog |
| 80 |
SELECT DISTINCT(File) FROM mysql.ndb_binlog_index; |
| 81 |
|
| 82 |
--echo # 6. Restart |
| 83 |
let $mysqld_name=mysqld.1.1; |
| 84 |
--source include/restart_mysqld.inc |
| 85 |
--source include/ndb_not_readonly.inc |
| 86 |
|
| 87 |
--echo # 7. Wait for 5 rows |
| 88 |
let $wait_condition= |
| 89 |
SELECT COUNT(File) = 5 FROM mysql.ndb_binlog_index; |
| 90 |
--source include/wait_condition.inc |
| 91 |
|
| 92 |
--echo # 8. Show that referenced rows are still there |
| 93 |
--replace_result $binlog_name binlog |
| 94 |
SELECT DISTINCT(File) FROM mysql.ndb_binlog_index; |
| 95 |
|
| 96 |
RESET MASTER; |
| 97 |
|