From 4feb9df105158eab216395db36ad5387d09d5cea Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 18 Aug 2022 16:21:31 +0530 Subject: [PATCH] MDEV-29282 atomic.rename_trigger fails occasionally This reverts part of commit 212994f704496d01881f377e34e04bd007e5e298 (MDEV-28974) and implements a better fix that works in that special case while avoiding other failures. fil_name_process(): Do not rename the tablespace in deferred_spaces; it already contains the latest name for the space id. deferred_spaces::create(): In mariadb-backup --prepare, replace absolute data directory file path with short name relative to the backup directory and store it as filename while deferring tablespace file creation. --- mysql-test/suite/atomic/disabled.def | 13 ------------- storage/innobase/log/log0recv.cc | 27 +++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 17 deletions(-) delete mode 100644 mysql-test/suite/atomic/disabled.def diff --git a/mysql-test/suite/atomic/disabled.def b/mysql-test/suite/atomic/disabled.def deleted file mode 100644 index 6d8defe344a..00000000000 --- a/mysql-test/suite/atomic/disabled.def +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# -# List the test cases that are to be disabled temporarily. -# -# Separate the test case name and the comment with ':'. -# -# : BUG# -# -# Do not use any TAB characters for whitespace. -# -############################################################################## - -rename_trigger : MDEV-29282 atomic.rename_trigger fails occasionly diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 9b6f778b859..fc2d50da62c 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -829,7 +829,29 @@ processed: fil_space_t *space= fil_space_t::create(it->first, flags, FIL_TYPE_TABLESPACE, crypt_data); ut_ad(space); - space->add(name.c_str(), OS_FILE_CLOSED, size, false, false); + const char *filename= name.c_str(); + if (srv_operation == SRV_OPERATION_RESTORE) + { + const char* tbl_name = strrchr(filename, '/'); +#ifdef _WIN32 + if (const char *last = strrchr(filename, '\\')) + { + if (last > tbl_name) + tbl_name = last; + } +#endif + if (tbl_name) + { + while (--tbl_name > filename && +#ifdef _WIN32 + *tbl_name != '\\' && +#endif + *tbl_name != '/'); + if (tbl_name > filename) + filename= tbl_name + 1; + } + } + space->add(filename, OS_FILE_CLOSED, size, false, false); space->recv_size= it->second.size; space->size_in_header= size; return space; @@ -1227,9 +1249,6 @@ static void fil_name_process(const char *name, ulint len, uint32_t space_id, d->deleted = true; goto got_deleted; } - if (ftype == FILE_RENAME) { - d->file_name= fname.name; - } goto reload; }