diff --git a/mysql-test/suite/innodb/r/tablespace_truncate_fil_shard.result b/mysql-test/suite/innodb/r/tablespace_truncate_fil_shard.result new file mode 100644 index 00000000000..29406c58bd8 --- /dev/null +++ b/mysql-test/suite/innodb/r/tablespace_truncate_fil_shard.result @@ -0,0 +1 @@ +"Test finished" diff --git a/mysql-test/suite/innodb/t/tablespace_truncate_fil_shard.test b/mysql-test/suite/innodb/t/tablespace_truncate_fil_shard.test new file mode 100644 index 00000000000..e51fdee2644 --- /dev/null +++ b/mysql-test/suite/innodb/t/tablespace_truncate_fil_shard.test @@ -0,0 +1,79 @@ +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_innodb_default_undo_tablespaces.inc + +--disable_query_log + +CREATE TABLE filler (id INT PRIMARY KEY, pad VARCHAR(200) NOT NULL) ENGINE=InnoDB; +INSERT INTO filler VALUES (1, REPEAT('x', 200)); +let $i = 13; +while ($i > 0) +{ + INSERT INTO filler SELECT id + (SELECT MAX(id) FROM filler), pad FROM filler; + --dec $i +} + +SET GLOBAL innodb_buf_flush_list_now = ON; +SET GLOBAL innodb_page_cleaner_disabled_debug = 1; +--let $open_files_limit = `SELECT @@GLOBAL.innodb_open_files` +DO innodb_set_open_files_limit(15); + +--connect(owner,localhost,root,,test) +CREATE TEMPORARY TABLE target (id INT PRIMARY KEY, pad VARCHAR(200) NOT NULL) ENGINE=InnoDB; +INSERT INTO target SELECT id, pad FROM filler; +--connection default + +SET GLOBAL innodb_buf_flush_list_now = ON; + +let $i = 0; +while ($i < 128) +{ + --eval CREATE TABLE donor_$i (id INT PRIMARY KEY) ENGINE=InnoDB + --eval INSERT INTO donor_$i VALUES (1) + --inc $i +} + +--connection owner +UPDATE target SET pad = CONCAT('y', SUBSTRING(pad, 2)) WHERE id >= 8000; +DROP TEMPORARY TABLE target; +let $owner_id = `SELECT CONNECTION_ID()`; + +--connect(flusher,localhost,root,,test) +SET SESSION DEBUG="+d,syncpoint_after_fil_open_file_releases_shard_for_open_limit"; +SET DEBUG_SYNC = 'after_fil_open_file_releases_shard_for_open_limit SIGNAL reached_after_fil_open_file_releases_shard_for_open_limit WAIT_FOR continue_after_fil_open_file_releases_shard_for_open_limit'; +--send SET GLOBAL innodb_buf_flush_list_now = ON + +--connection default +SET DEBUG_SYNC = 'now WAIT_FOR reached_after_fil_open_file_releases_shard_for_open_limit'; + +--disconnect owner + +let $wait_timeout = 60; +let $wait_condition = + SELECT COUNT(*) = 0 + FROM INFORMATION_SCHEMA.PROCESSLIST + WHERE ID = $owner_id; +--source include/wait_condition.inc + +SET DEBUG_SYNC = 'now SIGNAL continue_after_fil_open_file_releases_shard_for_open_limit'; + +--connection flusher +--reap +--disconnect flusher + +--connection default +SET GLOBAL innodb_page_cleaner_disabled_debug = 0; +--eval DO innodb_set_open_files_limit($open_files_limit) + +let $i = 0; +while ($i < 128) +{ + --eval DROP TABLE donor_$i; + --inc $i +} +DROP TABLE filler; + +--enable_query_log + +--echo "Test finished" + diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index e7520c82c18..58be257a016 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -45,6 +45,7 @@ The tablespace memory cache */ #include "buf0buf.h" #include "buf0flu.h" #include "clone0api.h" +#include "debug_sync.h" #include "dict0boot.h" #include "dict0dd.h" #include "dict0dict.h" @@ -2845,6 +2846,14 @@ dberr_t Fil_shard::open_file(fil_node_t *file) { if (!have_right_for_open) { mutex_release(); + DBUG_EXECUTE_IF( + "syncpoint_after_fil_open_file_releases_shard_for_open_limit", { + if (fsp_is_session_temporary(file->space->id)) { + DEBUG_SYNC(current_thd, + "after_fil_open_file_releases_shard_for_open_limit"); + } + }); + if (should_print_message( fil_system->m_TRYING_TO_OPEN_FILE_FOR_LONG_TIME_throttler)) { ib::warn warning(