| 1 |
--source include/have_debug.inc |
| 2 |
|
| 3 |
# Currently valgrind has issues with DBUG_SUICIDE() |
| 4 |
--source include/not_valgrind.inc |
| 5 |
|
| 6 |
# DEBUG_SYNC must be compiled in. |
| 7 |
--source include/have_debug_sync.inc |
| 8 |
|
| 9 |
--disable_query_log |
| 10 |
|
| 11 |
let $debug_test = 0; |
| 12 |
|
| 13 |
let $n_conn = 10; |
| 14 |
|
| 15 |
let $i = $n_conn; |
| 16 |
while ($i) { |
| 17 |
# If a row is less than half a page long, all of it is stored locally |
| 18 |
# within the page. The minimum page size is 4kB, so we should use row |
| 19 |
# with size < 2048 bytes. |
| 20 |
eval CREATE TABLE t$i (a INT PRIMARY KEY, b VARCHAR(1800)) ENGINE = InnoDB; |
| 21 |
eval INSERT INTO t$i (a, b) VALUES (0, ''); |
| 22 |
dec $i; |
| 23 |
} |
| 24 |
|
| 25 |
DELIMITER |; |
| 26 |
|
| 27 |
CREATE PROCEDURE mtr_redo_generate_single(IN tab INT, IN rec_size INT) |
| 28 |
BEGIN |
| 29 |
DECLARE max_a INT; |
| 30 |
SET @t = CONCAT("SELECT MAX(a)+1 FROM t", tab, " INTO @max_a"); |
| 31 |
PREPARE stmt_1 FROM @t; |
| 32 |
EXECUTE stmt_1; |
| 33 |
|
| 34 |
SET @t = CONCAT("INSERT INTO t", tab, " (a, b) " |
| 35 |
"VALUES (", @max_a, ", REPEAT('x', ", rec_size, "))"); |
| 36 |
PREPARE stmt_2 FROM @t; |
| 37 |
EXECUTE stmt_2; |
| 38 |
|
| 39 |
DEALLOCATE PREPARE stmt_2; |
| 40 |
DEALLOCATE PREPARE stmt_1; |
| 41 |
END| |
| 42 |
|
| 43 |
CREATE PROCEDURE mtr_redo_generate_multi(IN tab INT, IN rec_size INT, IN n INT) |
| 44 |
BEGIN |
| 45 |
DECLARE i INT DEFAULT 1; |
| 46 |
WHILE i <= n DO |
| 47 |
CALL mtr_redo_generate_single(tab, rec_size); |
| 48 |
SET i = i + 1; |
| 49 |
END WHILE; |
| 50 |
END| |
| 51 |
|
| 52 |
CREATE PROCEDURE mtr_noredo_generate_single() |
| 53 |
BEGIN |
| 54 |
DECLARE max_a INT; |
| 55 |
SELECT MAX(a)+1 FROM tmp_t INTO @max_a; |
| 56 |
INSERT INTO tmp_t (a, b) VALUES (@max_a, REPEAT('y', 1800)); |
| 57 |
END| |
| 58 |
|
| 59 |
CREATE PROCEDURE mtr_noredo_generate_multi(IN n INT) |
| 60 |
BEGIN |
| 61 |
DECLARE i INT DEFAULT 1; |
| 62 |
WHILE i <= n DO |
| 63 |
CALL mtr_noredo_generate_single(); |
| 64 |
SET i = i + 1; |
| 65 |
END WHILE; |
| 66 |
END| |
| 67 |
|
| 68 |
CREATE PROCEDURE mtr_noredo_update_all() |
| 69 |
BEGIN |
| 70 |
UPDATE tmp_t SET b = REPEAT('z', 1800); |
| 71 |
END| |
| 72 |
|
| 73 |
DELIMITER ;| |
| 74 |
|
| 75 |
--echo # |
| 76 |
--echo # BUG#27664539 INNODB: ASSERTION FAILURE: BUF0FLU.CC:457: |
| 77 |
--echo # (BUF_POOL->FLUSH_LIST).START == __NULL |
| 78 |
--echo # |
| 79 |
|
| 80 |
# We need to test two main scenarios in which mini-transaction with |
| 81 |
# MTR_LOG_NO_REDO can be involved: |
| 82 |
|
| 83 |
# 1. Pages dirtied without redo pretend to be inserted too quickly, |
| 84 |
# when the current lsn is far away in future in comparison to lsn |
| 85 |
# up to which we have finished inserting dirty pages to flush lists. |
| 86 |
# The interesting case happens when current lsn is greater than |
| 87 |
# log.recent_closed.tail() by more than log.recent_closed.capacity(). |
| 88 |
# |
| 89 |
# 2. Pages dirtied without redo pretend to be inserted too late, |
| 90 |
# with lsn which is smaller than log.recent_closed.tail(). |
| 91 |
# This might happen because they are not required to advance |
| 92 |
# the log.recent_closed.tail() because they did not generate |
| 93 |
# any redo records. However we need to be careful not to insert |
| 94 |
# pages dirtied without redo, with oldest_modification smaller |
| 95 |
# than checkpoint_lsn. |
| 96 |
# |
| 97 |
|
| 98 |
let $freeze_background_mtr = 1; |
| 99 |
|
| 100 |
--echo # |
| 101 |
--echo # Scenario 1.1.1 - No-redo dirtied page inserted too quickly. |
| 102 |
--echo # Non-empty flush list when it is inserted. |
| 103 |
--echo # The page is no-redo dirtied first time. |
| 104 |
--echo # |
| 105 |
--source ../include/log_flush_order_test_begin.inc |
| 106 |
let $noredo_remodify = 0; |
| 107 |
--source ../include/log_flush_order_test_too_fast.inc |
| 108 |
--source ../include/log_flush_order_test_end.inc |
| 109 |
|
| 110 |
--echo # |
| 111 |
--echo # Scenario 1.1.2 - No-redo dirtied page inserted too quickly. |
| 112 |
--echo # Non-empty flush list when it is inserted. |
| 113 |
--echo # The page is no-redo dirtied second time. |
| 114 |
--echo # |
| 115 |
--source ../include/log_flush_order_test_begin.inc |
| 116 |
let $noredo_remodify = 1; |
| 117 |
--source ../include/log_flush_order_test_too_fast.inc |
| 118 |
--source ../include/log_flush_order_test_end.inc |
| 119 |
|
| 120 |
--echo # |
| 121 |
--echo # Scenario 1.2.1 - No-redo dirtied page inserted too quickly. |
| 122 |
--echo # Empty flush list when it is inserted. |
| 123 |
--echo # The page is no-redo dirtied first time. |
| 124 |
--echo # |
| 125 |
--source ../include/log_flush_order_test_begin.inc |
| 126 |
let $noredo_remodify = 0; |
| 127 |
--source ../include/log_flush_order_test_too_fast_empty.inc |
| 128 |
--source ../include/log_flush_order_test_end.inc |
| 129 |
|
| 130 |
--echo # |
| 131 |
--echo # Scenario 1.2.2 - No-redo dirtied page inserted too quickly. |
| 132 |
--echo # Empty flush list when it is inserted. |
| 133 |
--echo # The page is no-redo dirtied second time, |
| 134 |
--echo # but it was flushed (empty flush list). |
| 135 |
--echo # |
| 136 |
--source ../include/log_flush_order_test_begin.inc |
| 137 |
let $noredo_remodify = 1; |
| 138 |
--source ../include/log_flush_order_test_too_fast_empty.inc |
| 139 |
--source ../include/log_flush_order_test_end.inc |
| 140 |
|
| 141 |
--echo # |
| 142 |
--echo # Scenario 2.1.1 - No-redo dirtied page inserted too late. |
| 143 |
--echo # Non-empty flush list when it is inserted. |
| 144 |
--echo # The page is no-redo dirtied first time. |
| 145 |
--echo # |
| 146 |
--source ../include/log_flush_order_test_begin.inc |
| 147 |
let $empty_flush_list = 0; |
| 148 |
let $noredo_remodify = 0; |
| 149 |
--source ../include/log_flush_order_test_too_slow.inc |
| 150 |
--source ../include/log_flush_order_test_end.inc |
| 151 |
|
| 152 |
--echo # |
| 153 |
--echo # Scenario 2.1.2 - No-redo dirtied page inserted too late. |
| 154 |
--echo # Non-empty flush list when it is inserted. |
| 155 |
--echo # The page is no-redo dirtied second time. |
| 156 |
--echo # |
| 157 |
--source ../include/log_flush_order_test_begin.inc |
| 158 |
let $empty_flush_list = 0; |
| 159 |
let $noredo_remodify = 1; |
| 160 |
--source ../include/log_flush_order_test_too_slow.inc |
| 161 |
--source ../include/log_flush_order_test_end.inc |
| 162 |
|
| 163 |
--echo # |
| 164 |
--echo # Scenario 2.2.1 - No-redo dirtied page inserted too late. |
| 165 |
--echo # Empty flush list when it is inserted. |
| 166 |
--echo # The page is no-redo dirtied first time. |
| 167 |
--echo # |
| 168 |
--source ../include/log_flush_order_test_begin.inc |
| 169 |
let $empty_flush_list = 1; |
| 170 |
let $noredo_remodify = 0; |
| 171 |
--source ../include/log_flush_order_test_too_slow.inc |
| 172 |
--source ../include/log_flush_order_test_end.inc |
| 173 |
|
| 174 |
--echo # |
| 175 |
--echo # Scenario 2.2.2 - No-redo dirtied page inserted too late. |
| 176 |
--echo # Empty flush list when it is inserted. |
| 177 |
--echo # The page is no-redo dirtied second time, |
| 178 |
--echo # but it was flushed (empty flush list). |
| 179 |
--echo # |
| 180 |
--source ../include/log_flush_order_test_begin.inc |
| 181 |
let $empty_flush_list = 1; |
| 182 |
let $noredo_remodify = 1; |
| 183 |
--source ../include/log_flush_order_test_too_slow.inc |
| 184 |
--source ../include/log_flush_order_test_end.inc |
| 185 |
|
| 186 |
--echo # |
| 187 |
--echo # Scenario 3 - Execute in parallel many redo and no-redo mini-transactions. |
| 188 |
--echo # Freeze and unfreeze recent_closed every 1s. |
| 189 |
--echo # |
| 190 |
|
| 191 |
let $freeze_background_mtr = 0; |
| 192 |
--source ../include/log_flush_order_test_begin.inc |
| 193 |
--source ../include/log_flush_order_test_random.inc |
| 194 |
--source ../include/log_flush_order_test_end.inc |
| 195 |
|
| 196 |
--echo # |
| 197 |
--echo # CLEANUP |
| 198 |
--echo # |
| 199 |
|
| 200 |
|
| 201 |
--disable_query_log |
| 202 |
DROP PROCEDURE mtr_redo_generate_single; |
| 203 |
DROP PROCEDURE mtr_redo_generate_multi; |
| 204 |
DROP PROCEDURE mtr_noredo_generate_single; |
| 205 |
DROP PROCEDURE mtr_noredo_generate_multi; |
| 206 |
DROP PROCEDURE mtr_noredo_update_all; |
| 207 |
|
| 208 |
let $i = $n_conn; |
| 209 |
while ($i) { |
| 210 |
eval DROP TABLE t$i; |
| 211 |
dec $i; |
| 212 |
} |
| 213 |
|
| 214 |
--enable_query_log |