| 1 |
################################################################################ |
| 2 |
# MDEV-32014 Rename binlog cache to binlog file |
| 3 |
# |
| 4 |
# It verifies that the rename logic is handled correct if error happens. |
| 5 |
################################################################################ |
| 6 |
--source include/have_binlog_format_row.inc |
| 7 |
--source include/have_innodb.inc |
| 8 |
--source include/have_debug.inc |
| 9 |
--source include/have_debug_sync.inc |
| 10 |
RESET MASTER; |
| 11 |
|
| 12 |
--echo # |
| 13 |
--echo # binlog cache file is created in #binlog_cache_files directory |
| 14 |
--echo # and it is deleted at disconnect |
| 15 |
--echo # |
| 16 |
--connect(con1,localhost,root,,) |
| 17 |
CREATE TABLE t1 (c1 LONGTEXT) ENGINE = InnoDB; |
| 18 |
|
| 19 |
--echo # list binlog_cache_files/ |
| 20 |
--let $datadir= `SELECT @@datadir` |
| 21 |
--list_files $datadir/#binlog_cache_files |
| 22 |
|
| 23 |
INSERT INTO t1 values(repeat("1", 5242880)); |
| 24 |
INSERT INTO t1 values(repeat("1", 5242880)); |
| 25 |
FLUSH BINARY LOGS; |
| 26 |
|
| 27 |
--echo # list #binlog_cache_files/ |
| 28 |
--replace_regex /ML_[0-9]+/ML_BINLOG_CACHE_FILE/ |
| 29 |
--list_files $datadir/#binlog_cache_files |
| 30 |
|
| 31 |
SET debug_sync = "thread_end SIGNAL signal.thread_end"; |
| 32 |
--disconnect con1 |
| 33 |
--connection default |
| 34 |
# Wait until the connection is closed completely. |
| 35 |
SET debug_sync = "now WAIT_FOR signal.thread_end"; |
| 36 |
|
| 37 |
--echo # binlog cache file is deleted at disconnection |
| 38 |
--echo # list #binlog_cache_files/ |
| 39 |
--list_files $datadir/#binlog_cache_files |
| 40 |
|
| 41 |
--echo # |
| 42 |
--echo # Reserved space is not big enough, rename will not happen. But rotate |
| 43 |
--echo # will succeed. |
| 44 |
--echo # |
| 45 |
SET GLOBAL binlog_large_commit_threshold = 10 * 1024 * 1024; |
| 46 |
SET debug = 'd,simulate_required_size_too_big'; |
| 47 |
UPDATE t1 SET c1 = repeat('2', 5242880); |
| 48 |
|
| 49 |
--let $gtid_end_pos= query_get_value(SHOW BINLOG EVENTS IN 'master-bin.000002' LIMIT 4, End_log_pos, 4) |
| 50 |
--let $assert_cond= $gtid_end_pos < 4096 |
| 51 |
--let $assert_text= Binlog is rotated, but rename is not executed. |
| 52 |
--source include/assert.inc |
| 53 |
|
| 54 |
--echo # |
| 55 |
--echo # Error happens when renaming binlog cache to binlog file, rename will |
| 56 |
--echo # not happen. Since the original binlog is delete, the rotate will failed |
| 57 |
--echo # too. binlog will be closed. |
| 58 |
--echo # |
| 59 |
SET debug = 'd,simulate_rename_binlog_cache_to_binlog_error'; |
| 60 |
--error ER_CANT_OPEN_FILE |
| 61 |
UPDATE t1 SET c1 = repeat('3', 5242880); |
| 62 |
SELECT count(*) FROM t1 WHERE c1 like "3%"; |
| 63 |
|
| 64 |
--echo # Binlog is closed |
| 65 |
--source include/show_master_status.inc |
| 66 |
|
| 67 |
--source include/restart_mysqld.inc |
| 68 |
--source include/show_master_status.inc |
| 69 |
|
| 70 |
--echo # |
| 71 |
--echo # Crash happens before rename the file |
| 72 |
--echo # |
| 73 |
SET GLOBAL binlog_large_commit_threshold = 10 * 1024 * 1024; |
| 74 |
|
| 75 |
SET debug = 'd,binlog_commit_by_rotate_crash_before_rename'; |
| 76 |
--source include/expect_crash.inc |
| 77 |
--error 2013 |
| 78 |
UPDATE t1 SET c1 = repeat('4', 5242880); |
| 79 |
|
| 80 |
--write_file $datadir/#binlog_cache_files/non_binlog_cache |
| 81 |
It is not a binlog cache file |
| 82 |
EOF |
| 83 |
|
| 84 |
--echo # One cache file left after crash |
| 85 |
--echo # list #binlog_cache_files/ |
| 86 |
--replace_regex /ML_[0-9]+/ML_BINLOG_CACHE_FILE/ |
| 87 |
--list_files $datadir/#binlog_cache_files |
| 88 |
|
| 89 |
--source include/start_mysqld.inc |
| 90 |
--echo # The cache file is deleted at startup. |
| 91 |
--echo # list #binlog_cache_files/ |
| 92 |
--list_files $datadir/#binlog_cache_files |
| 93 |
|
| 94 |
--let $assert_text= warning: non_binlog_cache file is in #binlog_cache_files/ |
| 95 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 96 |
--let $assert_select= non_binlog_cache.*#binlog_cache_files/ |
| 97 |
--let $assert_count= 1 |
| 98 |
--let $assert_only_after= CURRENT_TEST: binlog.binlog_commit_by_rotate_atomic |
| 99 |
--source include/assert_grep.inc |
| 100 |
|
| 101 |
--remove_file $datadir/#binlog_cache_files/non_binlog_cache |
| 102 |
|
| 103 |
--let $binlog_file= LAST |
| 104 |
--let $binlog_start= 4 |
| 105 |
--let $skip_checkpoint_events= 1 |
| 106 |
--source include/show_binlog_events.inc |
| 107 |
|
| 108 |
--echo # |
| 109 |
--echo # Crash happens just after rotation is finished, binlog commit is not |
| 110 |
--echo # started yet, so there is no Xid_log_event in the log, no garbage at |
| 111 |
--echo # the end of the file. |
| 112 |
--echo # |
| 113 |
SET GLOBAL binlog_large_commit_threshold = 10 * 1024 * 1024; |
| 114 |
|
| 115 |
BEGIN; |
| 116 |
UPDATE t1 SET c1 = repeat('5', 5242880); |
| 117 |
SAVEPOINT s1; |
| 118 |
UPDATE t1 SET c1 = repeat('6', 5242880); |
| 119 |
UPDATE t1 SET c1 = repeat('7', 5242880); |
| 120 |
ROLLBACK TO SAVEPOINT s1; |
| 121 |
INSERT INTO t1 VALUES('a'); |
| 122 |
|
| 123 |
SET debug = 'd,binlog_commit_by_rotate_crash_after_rotate'; |
| 124 |
--source include/expect_crash.inc |
| 125 |
--error 2013 |
| 126 |
COMMIT; |
| 127 |
|
| 128 |
--echo # No cache file left after crash |
| 129 |
--echo # list #binlog_cache_files/ |
| 130 |
--replace_regex /ML_[0-9]+/ML_BINLOG_CACHE_FILE/ |
| 131 |
--list_files $datadir/#binlog_cache_files |
| 132 |
|
| 133 |
--source include/start_mysqld.inc |
| 134 |
|
| 135 |
--let $binlog_file= master-bin.000006 |
| 136 |
--let $binlog_start= 4 |
| 137 |
--let $skip_checkpoint_events= 1 |
| 138 |
--source include/show_binlog_events.inc |
| 139 |
|
| 140 |
call mtr.add_suppression(".*Turning logging off for the whole duration.*"); |
| 141 |
call mtr.add_suppression(".*non_binlog_cache is in #binlog_cache_files/.*"); |
| 142 |
DROP TABLE t1; |
| 143 |
|