Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PXB-3034 Reduce the time the instance remains under lock #1530

Open
wants to merge 46 commits into
base: reducedlock-trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dec6cab
PXB-3034 - Make --lock-ddl option an ENUM
altmannmarcelo Nov 6, 2023
464c7b6
PXB-3034 - Add DDL tracking to xtrabackup
altmannmarcelo Nov 6, 2023
15d6004
PXB-3034 - Handle prepare
altmannmarcelo Nov 28, 2023
c3e0dd6
PXB-3034 - Second phase copy Multi thread
altmannmarcelo Nov 30, 2023
3d34e05
PXB-3034 - Adding test cases
altmannmarcelo Nov 6, 2023
756795d
PXB-3034 - adjust fil_open_for_xtrabackup
altmannmarcelo Dec 20, 2023
56a5adb
modifications
aybek Feb 15, 2024
0f5401d
handle renames during scan
aybek Feb 28, 2024
bedc607
We want to note that table will be copied only after it has been open…
aybek Mar 6, 2024
00ecb25
PXB-3113 : Improve debug sync framework to allow PXB to pause and res…
satya-bodapati Apr 2, 2024
7a81fd0
PXB-3252 : Xtrabackup failed to read page after 10 retries. File ./my…
satya-bodapati Apr 5, 2024
4e50fe9
PXB-3246 : Assertion failure: log0recv.cc:2141:!page || fil_page_type…
satya-bodapati Apr 5, 2024
3925f5b
PXB-3253 : [ERROR] [MY-012592] [InnoDB] Operating system error number…
satya-bodapati Apr 18, 2024
121b023
PXB-3223 : PXB must not allow --lock-ddl=REDUCED when pagetracking is…
satya-bodapati Apr 19, 2024
e71924a
PXB-3120 : Assertion failure: Dir_Walker::is_directory
satya-bodapati Apr 22, 2024
80ea4bb
PXB-3278 : Wrong parsing of MLOG_FILE_ redo log records with lock-ddl…
satya-bodapati Apr 25, 2024
1d1607f
Merge pull request #1552 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 25, 2024
d60a02c
PXB-3281 : With lock-ddl=REDUCED, STL containers used by reduced code…
satya-bodapati Apr 25, 2024
b5f4017
Merge pull request #1553 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 25, 2024
17121fe
PXB-3241 : Assertion failure: os0file.cc:3416:!exists while taking ba…
satya-bodapati Apr 26, 2024
36f8cbf
Merge pull request #1554 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 26, 2024
d5a4245
PXB-3245 : Assertion failure: fil0fil.cc:2545:err == DB_SUCCESS found…
satya-bodapati Apr 26, 2024
1a6b48a
Merge pull request #1555 from satya-bodapati/dev-reducedlock
satya-bodapati Apr 26, 2024
594da1d
PXB-3280 : undo log truncation causes assertion failure with reduced …
satya-bodapati May 2, 2024
c0302e8
Merge pull request #1556 from satya-bodapati/dev-reducedlock
satya-bodapati May 2, 2024
e95cb93
PXB-3248 Multiple files found for the same tablespace ID
aybek May 15, 2024
4b9f897
Merge pull request #1557 from aybek/dev-reducedlock-trunk
aybek May 15, 2024
caa4040
PXB-3248 Multiple files found for the same tablespace ID
aybek May 15, 2024
23136ed
Merge pull request #1558 from aybek/dev-reducedlock-trunk
aybek May 15, 2024
42cf484
PXB-3248 - Multiple files found for the same tablespace ID
aybek May 29, 2024
0108546
Merge pull request #1566 from aybek/dev-reducedlock-trunk2
aybek May 29, 2024
b8373d5
PXB-3034: Bring back UNIV_DEBUG on debug-sync-thread.
satya-bodapati Jun 7, 2024
d86332a
Merge pull request #1570 from satya-bodapati/dev-reducedlock
satya-bodapati Jun 9, 2024
a8eb932
PXB-3320 : prepare_handle_del_files() fails to delete the .meta and .…
satya-bodapati Jul 5, 2024
fc66022
Merge pull request #1584 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 15, 2024
c7cd826
PXB-3318 : prepare_handle_ren_files(): failed to handle .ren files
satya-bodapati Jul 16, 2024
1ad8fd9
Merge pull request #1585 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 16, 2024
620cd29
PXB-3295 : Undo tablespaces are not tracked properly with lock-ddl=RE…
satya-bodapati Jul 17, 2024
49c8a34
PXB-3295: fix testcase
satya-bodapati Jul 18, 2024
2fe6a4d
Merge pull request #1586 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 18, 2024
f55da87
Follow up fix for PXB-3318: handle rename source and destination as s…
satya-bodapati Jul 18, 2024
596352f
Merge pull request #1587 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 18, 2024
3099f59
PXB-3221 : Assertion failure: page0cur.cc:1177:ib::fatal triggered du…
satya-bodapati Jul 18, 2024
d525604
Merge pull request #1588 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 19, 2024
686c80c
PXB-3331 : Assertion failure: fil0fil.cc:6422:success
satya-bodapati Jul 22, 2024
3b41be9
Merge pull request #1590 from satya-bodapati/dev-reducedlock
satya-bodapati Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 63 additions & 32 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class Tablespace_dirs {

/** Discover tablespaces by reading the header from .ibd files.
@return DB_SUCCESS if all goes well */
[[nodiscard]] dberr_t scan(bool populate_fil_cache);
[[nodiscard]] dberr_t scan(bool populate_fil_cache, bool is_prep_handle_ddls);

/** Clear all the tablespace file data but leave the list of
scanned directories in place. */
Expand Down Expand Up @@ -678,7 +678,7 @@ class Tablespace_dirs {
@param[in] thread_id Thread ID
@param[out] result false in case of failure */
void open_ibd(const Const_iter &start, const Const_iter &end,
size_t thread_id, bool &result);
size_t thread_id, bool &result, bool is_prep_handle_ddls);

private:
/** Directories scanned and the files discovered under them. */
Expand Down Expand Up @@ -1643,6 +1643,8 @@ class Fil_system {
@return DB_SUCCESS if the open was successful */
[[nodiscard]] dberr_t open_for_recovery(space_id_t space_id);

[[nodiscard]] dberr_t open_for_prepare(const std::string &path);

/** This function should be called after recovery has completed.
Check for tablespace files for which we did not see any
MLOG_FILE_DELETE or MLOG_FILE_RENAME record. These could not
Expand Down Expand Up @@ -1699,8 +1701,8 @@ class Fil_system {

/** Scan the directories to build the tablespace ID to file name
mapping table. */
dberr_t scan(bool populate_fil_cache) {
return (m_dirs.scan(populate_fil_cache));
dberr_t scan(bool populate_fil_cache, bool is_prep_handle_ddls) {
return (m_dirs.scan(populate_fil_cache, is_prep_handle_ddls));
}

/** Open all known tablespaces. */
Expand Down Expand Up @@ -1825,7 +1827,6 @@ class Fil_system {
void meb_name_process(char *name, space_id_t space_id, bool deleted);

#endif /* UNIV_HOTBACKUP */

private:
/** Open an ibd tablespace and add it to the InnoDB data structures.
This is similar to fil_ibd_open() except that it is used while
Expand Down Expand Up @@ -10190,6 +10191,22 @@ dberr_t fil_tablespace_open_for_recovery(space_id_t space_id) {
return fil_system->open_for_recovery(space_id);
}

dberr_t Fil_system::open_for_prepare(const std::string &path) {
space_id_t space_id = get_tablespace_id(path);
fil_space_t *space;

auto status = ibd_open_for_recovery(space_id, path, space);

if (status == FIL_LOAD_DBWLR_CORRUPTION) {
return DB_CORRUPTION;
}
return DB_SUCCESS;
}

dberr_t fil_open_for_prepare(const std::string &path) {
return fil_system->open_for_prepare(path);
}

Fil_state fil_tablespace_path_equals(space_id_t space_id,
const char *space_name, ulint fsp_flags,
std::string old_path,
Expand Down Expand Up @@ -11635,7 +11652,8 @@ std::tuple<dberr_t, space_id_t> fil_open_for_xtrabackup(
@param[in] thread_id Thread ID
@param[in,out] result result of the open */
void Tablespace_dirs::open_ibd(const Const_iter &start, const Const_iter &end,
size_t thread_id, bool &result) {
size_t thread_id, bool &result,
bool is_prep_handle_ddls) {
if (!result) return;

for (auto it = start; it != end; ++it) {
Expand All @@ -11647,28 +11665,37 @@ void Tablespace_dirs::open_ibd(const Const_iter &start, const Const_iter &end,
continue;
}

/* cannot use auto [err, space_id] = fil_open_for_xtrabackup() as space_id
is unused here and we get unused variable error during compilation */
dberr_t err;
std::tie(err, std::ignore) = fil_open_for_xtrabackup(
phy_filename, filename.substr(0, filename.length() - 4));

/* Allow deleted tables between disovery and file open when
LOCK_DDL_REDUCED, they will be handled by ddl_tracker */
if (err == DB_CANNOT_OPEN_FILE && opt_lock_ddl == LOCK_DDL_REDUCED) {
ddl_tracker->add_missing_table(phy_filename);
} else if (err == DB_TABLESPACE_EXISTS &&
opt_lock_ddl == LOCK_DDL_REDUCED) {
/* table was renamed during scan. Since original table was loaded to cache
and rename ddl will be handled by ddl_tracker we skip loading
duplicate tablespace */
continue;
} else
/* PXB-2275 - Allow DB_INVALID_ENCRYPTION_META as we will test it in
the end of the backup */
if (err != DB_SUCCESS && err != DB_INVALID_ENCRYPTION_META) {
/* when processing ddl files on prepare phase we should load data files
without first page validation */
if (is_prep_handle_ddls) {
dberr_t err = fil_open_for_prepare(phy_filename);
if (err != DB_SUCCESS) {
result = false;
}
} else {
/* cannot use auto [err, space_id] = fil_open_for_xtrabackup() as space_id
is unused here and we get unused variable error during compilation */
dberr_t err;
std::tie(err, std::ignore) = fil_open_for_xtrabackup(
phy_filename, filename.substr(0, filename.length() - 4));

/* Allow deleted tables between disovery and file open when
LOCK_DDL_REDUCED, they will be handled by ddl_tracker */
if (err == DB_CANNOT_OPEN_FILE && opt_lock_ddl == LOCK_DDL_REDUCED) {
ddl_tracker->add_missing_table(phy_filename);
} else if (err == DB_TABLESPACE_EXISTS &&
opt_lock_ddl == LOCK_DDL_REDUCED) {
/* table was renamed during scan. Since original table was loaded to
cache and rename ddl will be handled by ddl_tracker we skip loading
duplicate tablespace */
continue;
} else
/* PXB-2275 - Allow DB_INVALID_ENCRYPTION_META as we will test it in
the end of the backup */
if (err != DB_SUCCESS && err != DB_INVALID_ENCRYPTION_META) {
result = false;
}
}
}
}

Expand Down Expand Up @@ -11939,7 +11966,8 @@ void Tablespace_dirs::set_scan_dirs(const std::string &in_directories) {
/** Discover tablespaces by reading the header from .ibd files.
@param[in] in_directories Directories to scan
@return DB_SUCCESS if all goes well */
dberr_t Tablespace_dirs::scan(bool populate_fil_cache) {
dberr_t Tablespace_dirs::scan(bool populate_fil_cache,
bool is_prep_handle_ddls) {
Scanned_files ibd_files;
Scanned_files undo_files;
uint16_t count = 0;
Expand Down Expand Up @@ -12055,10 +12083,12 @@ dberr_t Tablespace_dirs::scan(bool populate_fil_cache) {

if (err == DB_SUCCESS && populate_fil_cache) {
bool result = true;
std::function<void(const Const_iter &, const Const_iter &, size_t, bool &)>
open = std::bind(&Tablespace_dirs::open_ibd, this, _1, _2, _3, _4);
std::function<void(const Const_iter &, const Const_iter &, size_t, bool &,
bool)>
open = std::bind(&Tablespace_dirs::open_ibd, this, _1, _2, _3, _4, _5);

par_for(PFS_NOT_INSTRUMENTED, ibd_files, n_threads, open, result);
par_for(PFS_NOT_INSTRUMENTED, ibd_files, n_threads, open, result,
is_prep_handle_ddls);

if (!result) err = DB_FAIL;
}
Expand All @@ -12077,8 +12107,9 @@ void fil_set_scan_dirs(const std::string &directories) {
/** Discover tablespaces by reading the header from .ibd files.
@param[in] populate_fil_cache Whether to load tablespaces into fil cache
@return DB_SUCCESS if all goes well */
dberr_t fil_scan_for_tablespaces(bool populate_fil_cache) {
return (fil_system->scan(populate_fil_cache));
dberr_t fil_scan_for_tablespaces(bool populate_fil_cache,
bool is_prep_handle_ddls) {
return (fil_system->scan(populate_fil_cache, is_prep_handle_ddls));
}

/** Open all known tablespaces. */
Expand Down
7 changes: 6 additions & 1 deletion storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2241,15 +2241,20 @@ void fil_set_scan_dirs(const std::string &directories);

/** Discover tablespaces by reading the header from .ibd files.
@param[in] populate_fil_cache Whether to load tablespaces into fil cache
@param[in] is_prep_handle_ddls Whether loading tablespaces on prepare phase
to handle the ddls
@return DB_SUCCESS if all goes well */
dberr_t fil_scan_for_tablespaces(bool populate_fil_cache);
dberr_t fil_scan_for_tablespaces(bool populate_fil_cache,
bool is_prep_handle_ddls);

/** Open the tablespace and also get the tablespace filenames, space_id must
already be known.
@param[in] space_id Tablespace ID to lookup
@return DB_SUCCESS if open was successful */
[[nodiscard]] dberr_t fil_tablespace_open_for_recovery(space_id_t space_id);

dberr_t fil_open_for_prepare(const std::string &path);

/** Replay a file rename operation for ddl replay.
@param[in] page_id Space ID and first page number in the file
@param[in] old_name old file name
Expand Down
4 changes: 3 additions & 1 deletion storage/innobase/os/os0enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ bool Encryption::decode_encryption_info(space_id_t space_id,
encryption info maybe hasn't written into datafile when
the table is newly created. For clone encryption information
should have been already correct. */
return (recv_recovery_is_on() ? true : false);
bool prep_lock_ddl_reduced =
!srv_backup_mode && opt_lock_ddl == LOCK_DDL_REDUCED;
return (recv_recovery_is_on() || prep_lock_ddl_reduced ? true : false);
} else {
ib::error(ER_IB_MSG_837) << "Failed to decrypt encryption information,"
<< " found unexpected version of it!";
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ dberr_t srv_start(bool create_new_db IF_XB(, lsn_t to_lsn)) {
return (srv_init_abort(err));
}

err = fil_scan_for_tablespaces(false);
err = fil_scan_for_tablespaces(false, false);

if (err != DB_SUCCESS) {
return (srv_init_abort(err));
Expand Down
9 changes: 4 additions & 5 deletions storage/innobase/xtrabackup/src/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,7 @@ static bool innodb_init_param(void) {
return (true);
}

static void xb_scan_for_tablespaces() {
static void xb_scan_for_tablespaces(bool is_prep_handle_ddls) {
/* This is the default directory for IBD and IBU files. Put it first
in the list of known directories. */
fil_set_scan_dir(MySQL_datadir_path.path());
Expand All @@ -2484,7 +2484,7 @@ static void xb_scan_for_tablespaces() {
--innodb-undo-directory also. */
fil_set_scan_dir(Fil_path::remove_quotes(MySQL_undo_path), true);

if (fil_scan_for_tablespaces(true) != DB_SUCCESS) {
if (fil_scan_for_tablespaces(true, is_prep_handle_ddls) != DB_SUCCESS) {
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -3611,7 +3611,7 @@ static dberr_t xb_load_tablespaces(bool is_prep_handle_ddls)
}

xb::info() << "Generating a list of tablespaces";
xb_scan_for_tablespaces();
xb_scan_for_tablespaces(is_prep_handle_ddls);

/* Add separate undo tablespaces to fil_system */

Expand All @@ -3625,8 +3625,7 @@ static dberr_t xb_load_tablespaces(bool is_prep_handle_ddls)
/* when processing ddl files on prepare phase we should load data files
without first page validation */
if (is_prep_handle_ddls) {
space_id_t space_id = fil_get_tablespace_id(tablespace.file_name);
dberr_t err = fil_tablespace_open_for_recovery(space_id);
dberr_t err = fil_open_for_prepare(tablespace.file_name);
if (err != DB_SUCCESS) {
return (err);
}
Expand Down
Loading