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
parent 77c4c0f2
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 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 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; CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
DROP TABLE t1; DROP TABLE t1;
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/not_embedded.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 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_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; let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
......
...@@ -66,9 +66,10 @@ inline bool fil_is_user_tablespace_id(ulint space_id) ...@@ -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. /** 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 @param print_info whether to diagnose why a file cannot be closed
@return whether a file was 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)); ut_ad(mutex_own(&fil_system.mutex));
for (fil_space_t *space= UT_LIST_GET_FIRST(fil_system.space_list); space; 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) ...@@ -80,7 +81,8 @@ bool fil_space_t::try_to_close(bool print_info)
case FIL_TYPE_IMPORT: case FIL_TYPE_IMPORT:
break; break;
case FIL_TYPE_TABLESPACE: case FIL_TYPE_TABLESPACE:
if (!fil_is_user_tablespace_id(space->id)) if (space == ignore_space
|| !fil_is_user_tablespace_id(space->id))
continue; continue;
} }
...@@ -354,7 +356,7 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle, ...@@ -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); n_pending.fetch_and(~CLOSING, std::memory_order_relaxed);
if (++fil_system.n_open >= srv_max_n_open_files) { if (++fil_system.n_open >= srv_max_n_open_files) {
reacquire(); reacquire();
try_to_close(true); try_to_close(this, true);
release(); release();
} }
} }
...@@ -405,7 +407,7 @@ static bool fil_node_open_file_low(fil_node_t *node) ...@@ -405,7 +407,7 @@ static bool fil_node_open_file_low(fil_node_t *node)
/* The following call prints an error message */ /* The following call prints an error message */
if (os_file_get_last_error(true) == EMFILE + 100 && 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; continue;
ib::warn() << "Cannot open '" << node->name << "'."; ib::warn() << "Cannot open '" << node->name << "'.";
...@@ -449,7 +451,7 @@ static bool fil_node_open_file(fil_node_t *node) ...@@ -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++) 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; count= 0;
else if (count >= 2) else if (count >= 2)
{ {
......
...@@ -590,9 +590,10 @@ struct fil_space_t final ...@@ -590,9 +590,10 @@ struct fil_space_t final
public: public:
/** Try to close a file to adhere to the innodb_open_files limit. /** 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 @param print_info whether to diagnose why a file cannot be closed
@return whether a file was 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 */ /** Close all tablespace files at shutdown */
static void close_all(); static void close_all();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment