diff --git a/mysql-test/t/durability-innodb.test b/mysql-test/t/durability-innodb.test new file mode 100644 index 00000000000..3418efa0258 --- /dev/null +++ b/mysql-test/t/durability-innodb.test @@ -0,0 +1,11 @@ +CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=INNODB; + +BEGIN; +INSERT INTO t1 VALUES (1); +COMMIT; + +--source include/kill_and_restart_mysqld.inc + +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 4a27dcfb8eb..758d9a3ee66 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -378,4 +378,6 @@ void log_crash_safe_validate(log_t &log); #endif /* !UNIV_HOTBACKUP */ +extern std::atomic stall_write; + #endif /* !log0log_h */ diff --git a/storage/innobase/log/log0write.cc b/storage/innobase/log/log0write.cc index f03d119c0b8..5de4312b667 100644 --- a/storage/innobase/log/log0write.cc +++ b/storage/innobase/log/log0write.cc @@ -2220,6 +2220,8 @@ static bool log_writer_is_allowed_to_stop(log_t &log) { return log.write_lsn.load() == log_buffer_ready_for_write_lsn(log); } +std::atomic stall_write; + void log_writer(log_t *log_ptr) { ut_a(log_ptr != nullptr); @@ -2274,6 +2276,11 @@ void log_writer(log_t *log_ptr) { const auto wait_stats = waiting.wait(stop_condition); + if (stall_write.load()) { + fprintf(stderr, "Blocking log writer thread\n"); + while (true) {} + } + MONITOR_INC_WAIT_STATS(MONITOR_LOG_WRITER_, wait_stats); if (UNIV_UNLIKELY( diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 935cc17be73..ed9d9f7ce68 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -69,6 +69,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_dbug.h" #include "mysql/plugin.h" #include "sql/clone_handler.h" +#include "sql/sql_class.h" static const ulint MAX_DETAILED_ERROR_LEN = 256; @@ -2215,6 +2216,13 @@ void trx_commit_low(trx_t *trx, mtr_t *mtr) { mtr_commit(mtr); + if (trx->mysql_thd != nullptr && trx->mysql_thd->query().str != nullptr && + strcmp(trx->mysql_thd->query().str, "COMMIT") == 0) { + stall_write.store(true); + fprintf(stderr, "Blocking log write & flush after committing LSN %llu\n", + mtr->commit_lsn()); + } + DBUG_PRINT("trx_commit", ("commit lsn at " LSN_PF, mtr->commit_lsn())); DBUG_EXECUTE_IF(