Skip to content

Commit 4b4dbb2

Browse files
MDEV-34169 Don't allow innodb_open_files to be lesser than
number of non-user tablespace. fil_space_t::try_to_close(): Don't try to close the tablespace which is acquired by the caller of the function Added the suppression message in open_files_limit test case
1 parent 77c4c0f commit 4b4dbb2

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is not greater than the number of system tablespace files, temporary tablespace files, innodb_undo_tablespaces=.*");
2+
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is exceeded \\(.* files stay open\\)");
23
FOUND 1 /\[Warning\] InnoDB: innodb_open_files=.* is not greater than the number of system tablespace files, temporary tablespace files, innodb_undo_tablespaces=.*/ in mysqld.1.err
34
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
45
DROP TABLE t1;

mysql-test/suite/innodb/t/open_files_limit.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--source include/have_innodb.inc
22
--source include/not_embedded.inc
33
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is not greater than the number of system tablespace files, temporary tablespace files, innodb_undo_tablespaces=.*");
4+
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is exceeded \\(.* files stay open\\)");
45
let SEARCH_PATTERN= \[Warning\] InnoDB: innodb_open_files=.* is not greater than the number of system tablespace files, temporary tablespace files, innodb_undo_tablespaces=.*;
56
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
67
--source include/search_pattern_in_file.inc

storage/innobase/fil/fil0fil.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ inline bool fil_is_user_tablespace_id(ulint space_id)
6666
}
6767

6868
/** Try to close a file to adhere to the innodb_open_files limit.
69+
@param ignore_space Ignore the tablespace which is acquired by caller
6970
@param print_info whether to diagnose why a file cannot be closed
7071
@return whether a file was closed */
71-
bool fil_space_t::try_to_close(bool print_info)
72+
bool fil_space_t::try_to_close(fil_space_t *ignore_space, bool print_info)
7273
{
7374
ut_ad(mutex_own(&fil_system.mutex));
7475
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space;
@@ -80,7 +81,8 @@ bool fil_space_t::try_to_close(bool print_info)
8081
case FIL_TYPE_IMPORT:
8182
break;
8283
case FIL_TYPE_TABLESPACE:
83-
if (!fil_is_user_tablespace_id(space->id))
84+
if (space == ignore_space
85+
|| !fil_is_user_tablespace_id(space->id))
8486
continue;
8587
}
8688

@@ -354,7 +356,7 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
354356
n_pending.fetch_and(~CLOSING, std::memory_order_relaxed);
355357
if (++fil_system.n_open >= srv_max_n_open_files) {
356358
reacquire();
357-
try_to_close(true);
359+
try_to_close(this, true);
358360
release();
359361
}
360362
}
@@ -405,7 +407,7 @@ static bool fil_node_open_file_low(fil_node_t *node)
405407

406408
/* The following call prints an error message */
407409
if (os_file_get_last_error(true) == EMFILE + 100 &&
408-
fil_space_t::try_to_close(true))
410+
fil_space_t::try_to_close(nullptr, true))
409411
continue;
410412

411413
ib::warn() << "Cannot open '" << node->name << "'.";
@@ -449,7 +451,7 @@ static bool fil_node_open_file(fil_node_t *node)
449451

450452
for (ulint count= 0; fil_system.n_open >= srv_max_n_open_files; count++)
451453
{
452-
if (fil_space_t::try_to_close(count > 1))
454+
if (fil_space_t::try_to_close(nullptr, count > 1))
453455
count= 0;
454456
else if (count >= 2)
455457
{

storage/innobase/include/fil0fil.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,10 @@ struct fil_space_t final
590590

591591
public:
592592
/** Try to close a file to adhere to the innodb_open_files limit.
593+
@param ignore_space Ignore the tablespace which is acquired by caller
593594
@param print_info whether to diagnose why a file cannot be closed
594595
@return whether a file was closed */
595-
static bool try_to_close(bool print_info);
596+
static bool try_to_close(fil_space_t *ignore_space, bool print_info);
596597

597598
/** Close all tablespace files at shutdown */
598599
static void close_all();

0 commit comments

Comments
 (0)