diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2023-03-06 19:09:13 +0300 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2023-03-10 18:31:10 +0300 |
commit | 7d6b3d40085562d6f9f110f4ba921cf061548844 (patch) | |
tree | 35d675fb57b6e06ab0ddc5e1cde8b13d3c5ad6cb /extra | |
parent | 08267ba0c88d2f3ba1bacee9bb9a1e4da921a60a (diff) | |
download | mariadb-git-7d6b3d40085562d6f9f110f4ba921cf061548844.tar.gz |
MDEV-30775 Performance regression in fil_space_t::try_to_close() introduced in MDEV-23855
fil_node_open_file_low() tries to close files from the top of
fil_system.space_list if the number of opened files is exceeded.
It invokes fil_space_t::try_to_close(), which iterates the list searching
for the first opened space. Then it just closes the space, leaving it in
the same position in fil_system.space_list.
On heavy files opening, like during 'SHOW TABLE STATUS ...' execution,
if the number of opened files limit is reached,
fil_space_t::try_to_close() iterates more and more closed spaces before
reaching any opened space for each fil_node_open_file_low() call. What
causes performance regression if the number of spaces is big enough.
The fix is to keep opened spaces at the top of fil_system.space_list,
and move closed files at the end of the list.
For this purpose fil_space_t::space_list_last_opened pointer is
introduced. It points to the last inserted opened space in
fil_space_t::space_list. When space is opened, it's inserted to the
position just after the pointer points to in fil_space_t::space_list to
preserve the logic, inroduced in MDEV-23855. Any closed space is added
to the end of fil_space_t::space_list.
As opened spaces are located at the top of fil_space_t::space_list,
fil_space_t::try_to_close() finds opened space faster.
There can be the case when opened and closed spaces are mixed in
fil_space_t::space_list if fil_system.freeze_space_list was set during
fil_node_open_file_low() execution. But this should not cause any error,
as fil_space_t::try_to_close() still iterates spaces in the list.
There is no need in any test case for the fix, as it does not change any
functionality, but just fixes performance regression.
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 522072a05fd..c57c2685c94 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3361,7 +3361,9 @@ static void xb_load_single_table_tablespace(const char *dirname, if (err == DB_SUCCESS && file->space_id() != SRV_TMP_SPACE_ID) { space = fil_space_t::create( name, file->space_id(), file->flags(), - FIL_TYPE_TABLESPACE, NULL/* TODO: crypt_data */); + FIL_TYPE_TABLESPACE, NULL/* TODO: crypt_data */, + FIL_ENCRYPTION_DEFAULT, + file->handle() != OS_FILE_CLOSED); ut_a(space != NULL); space->add(file->filepath(), @@ -5242,7 +5244,8 @@ exit: ut_ad(fil_space_t::physical_size(flags) == info.page_size); if (fil_space_t::create(dest_space_name, info.space_id, flags, - FIL_TYPE_TABLESPACE, 0)) { + FIL_TYPE_TABLESPACE, 0, FIL_ENCRYPTION_DEFAULT, + true)) { *success = xb_space_create_file(real_name, info.space_id, flags, &file); } else { |