Skip to content

Commit

Permalink
MDEV-34169 Don't allow innodb_open_files to be lesser than
Browse files Browse the repository at this point in the history
              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
  • Loading branch information
Thirunarayanan committed Jun 7, 2024
1 parent 77c4c0f commit 4b4dbb2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/r/open_files_limit.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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=.*");
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is exceeded \\(.* files stay open\\)");
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
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
DROP TABLE t1;
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/t/open_files_limit.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
--source include/have_innodb.inc
--source include/not_embedded.inc
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=.*");
call mtr.add_suppression("\\[Warning\\] InnoDB: innodb_open_files=.* is exceeded \\(.* files stay open\\)");
let SEARCH_PATTERN= \[Warning\] InnoDB: innodb_open_files=.* is not greater than the number of system tablespace files, temporary tablespace files, innodb_undo_tablespaces=.*;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--source include/search_pattern_in_file.inc
Expand Down
12 changes: 7 additions & 5 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ inline bool fil_is_user_tablespace_id(ulint space_id)
}

/** Try to close a file to adhere to the innodb_open_files limit.
@param ignore_space Ignore the tablespace which is acquired by caller
@param print_info whether to diagnose why a file cannot be closed
@return whether a file was closed */
bool fil_space_t::try_to_close(bool print_info)
bool fil_space_t::try_to_close(fil_space_t *ignore_space, bool print_info)
{
ut_ad(mutex_own(&fil_system.mutex));
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space;
Expand All @@ -80,7 +81,8 @@ bool fil_space_t::try_to_close(bool print_info)
case FIL_TYPE_IMPORT:
break;
case FIL_TYPE_TABLESPACE:
if (!fil_is_user_tablespace_id(space->id))
if (space == ignore_space
|| !fil_is_user_tablespace_id(space->id))
continue;
}

Expand Down Expand Up @@ -354,7 +356,7 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
n_pending.fetch_and(~CLOSING, std::memory_order_relaxed);
if (++fil_system.n_open >= srv_max_n_open_files) {
reacquire();
try_to_close(true);
try_to_close(this, true);
release();
}
}
Expand Down Expand Up @@ -405,7 +407,7 @@ static bool fil_node_open_file_low(fil_node_t *node)

/* The following call prints an error message */
if (os_file_get_last_error(true) == EMFILE + 100 &&
fil_space_t::try_to_close(true))
fil_space_t::try_to_close(nullptr, true))
continue;

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

for (ulint count= 0; fil_system.n_open >= srv_max_n_open_files; count++)
{
if (fil_space_t::try_to_close(count > 1))
if (fil_space_t::try_to_close(nullptr, count > 1))
count= 0;
else if (count >= 2)
{
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,10 @@ struct fil_space_t final

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

/** Close all tablespace files at shutdown */
static void close_all();
Expand Down

0 comments on commit 4b4dbb2

Please sign in to comment.