commit 08d2cdd7af03c3d6dfe0fdcfc078a7a8990c44b7 Author: zhongbei.yk Date: Tue Sep 24 19:06:19 2024 +0800 crash recovery is slow diff --git a/mysql-test/t/crash_recovery_is_slow.test b/mysql-test/t/crash_recovery_is_slow.test new file mode 100644 index 00000000000..884e9887429 --- /dev/null +++ b/mysql-test/t/crash_recovery_is_slow.test @@ -0,0 +1,50 @@ +# OSS Table support for DML with +# --source include/have_debug.inc +--source include/have_binlog_format_row.inc + +call mtr.add_suppression(".*Assertion failure.*"); + +--echo ########################### +--echo # 1. Prepare +--echo ########################### +--disable_query_log +--disable_result_log + +CREATE TABLE articles ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + body TEXT NOT NULL +) ENGINE=InnoDB; + +delimiter $$; +CREATE PROCEDURE create_tables(IN num INTEGER) + BEGIN + DECLARE tableName VARCHAR(255); + declare x INT; + set x = 1; + while x < num do + START TRANSACTION; + insert into articles (`title`, `body`) VALUES (repeat('yes', 60), repeat('mysql', 1200)); + COMMIT; + set x = x + 1; + end while; +end$$ +delimiter ;$$ + +SET GLOBAL innodb_log_checkpoint_now = 1; +SET GLOBAL innodb_checkpoint_disabled = ON; + +set global debug='+d,ib_posix_fallocate_fail_disk'; + +--source include/expect_crash.inc +--error 2013 +CALL create_tables(100000); + +--echo # After Crash Recovery +--source include/start_mysqld_no_echo.inc + +--enable_query_log +--enable_result_log + +DROP PROCEDURE create_tables; +DROP TABLE articles; diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 62695d5e433..fdfa8c3b1fd 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -2495,9 +2495,15 @@ dberr_t dblwr::write(buf_flush_t flush_type, buf_page_t *bpage, return DB_SUCCESS; } + if (srv_read_only_mode || fsp_is_system_temporary(space_id) || !dblwr::is_enabled() || Double_write::s_instances == nullptr || - mtr_t::s_logging.dblwr_disabled()) { + mtr_t::s_logging.dblwr_disabled() + // Skip the other spaces over double-write so that only pages with space + // id with 6 are kept in double-write. + // the table with space_id = 6 is the table articles we created in + // crash_recovery_is_slow.test + || space_id != 6) { /* Skip the double-write buffer since it is not needed. Temporary tablespaces are never recovered, therefore we don't care about torn writes. */ @@ -3041,6 +3047,11 @@ bool dblwr::recv::Pages::dblwr_recover_page(page_no_t dblwr_page_no, request.dblwr(); + + // Print the page that double-wirte did + ib::info(ER_IB_MSG_DBLWR_1311) << "do io for dblwr page " << space->id + << " page " << page_no; + /* Read in the page from the data file to compare. */ auto err = fil_io(request, true, page_id, page_size, 0, page_size.physical(), buffer.begin(), nullptr); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 8cb05aed7ac..032ebc56406 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6671,6 +6671,18 @@ bool Fil_shard::space_extend(fil_space_t *space, page_no_t size) { DBUG_EXECUTE_IF("ib_posix_fallocate_fail_einval", ret = EINVAL;); + int j = 0; + DBUG_EXECUTE_IF("ib_posix_fallocate_fail_disk", j = 1;); + + static int i = 0; + + // Generates 30 space-extend + if (j == 1) { + ib::info() << "extend count: " << i; + i++; + if (i == 30) ut_a(0); + } + if (ret != 0) { /* We already pass the valid offset and len in, if EINVAL is returned, it could only mean that the file system doesn't @@ -10370,6 +10382,10 @@ byte *fil_tablespace_redo_extend(byte *ptr, const byte *end, bool parse_only) { ut_a(page_id.page_no() == 0); + // Prints logs for redo extend + ib::info() << "MLOG_FILE_EXTEND: space " << page_id.space() << " page " + << page_id.page_no(); + /* We never recreate the system tablespace. */ ut_a(page_id.space() != TRX_SYS_SPACE);