Skip to content

Commit

Permalink
Addressing the PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aibek Bukabayev committed Aug 30, 2024
1 parent 65300ae commit 2a98596
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 100 deletions.
46 changes: 33 additions & 13 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,9 @@ class Fil_system {
@return DB_SUCCESS if the open was successful */
[[nodiscard]] dberr_t open_for_recovery(space_id_t space_id);

/** Open a tablespace when LOCK_DDL_REDUCED is on.
@param[in] path File path
@return DB_SUCCESS if the open was successful */
[[nodiscard]] dberr_t open_for_reduced(const std::string &path);

/** This function should be called after recovery has completed.
Expand Down Expand Up @@ -3398,9 +3401,11 @@ bool fil_space_free(space_id_t space_id, bool x_latched) {
return true;
}

#ifdef XTRABACKUP
space_id_t fil_get_tablespace_id(const std::string &filename) {
return Fil_system::get_tablespace_id(filename);
}
#endif /* XTRABACKUP */

#ifdef UNIV_HOTBACKUP
/** Frees a space object from the tablespace memory cache.
Expand Down Expand Up @@ -10212,12 +10217,23 @@ dberr_t Fil_system::open_for_reduced(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);
switch (ibd_open_for_recovery(space_id, path, space)) {
case FIL_LOAD_NOT_FOUND:
return DB_TABLESPACE_NOT_FOUND;

if (status == FIL_LOAD_DBWLR_CORRUPTION) {
return DB_CORRUPTION;
case FIL_LOAD_DBWLR_CORRUPTION:
return DB_CORRUPTION;

case FIL_LOAD_INVALID_ENCRYPTION_META:
return DB_INVALID_ENCRYPTION_META;

case FIL_LOAD_INVALID:
case FIL_LOAD_MISMATCH:
case FIL_LOAD_ID_CHANGED:
return DB_CANNOT_OPEN_FILE;
default:
return DB_SUCCESS;
}
return DB_SUCCESS;
}

dberr_t fil_open_for_reduced(const std::string &path) {
Expand Down Expand Up @@ -10546,12 +10562,12 @@ static void fil_make_abs_file_path(const char *file_name, ulint flags,
@param[in] page_id Tablespace Id and first page in file
@param[in] parsed_bytes Number of bytes parsed so far
@param[in] parse_only Don't apply, parse only
@param[in] start_lsn LSN of the redo record
@param[in] record_lsn LSN of the redo record
@return pointer to next redo log record
@retval nullptr if this log record was truncated */
const byte *fil_tablespace_redo_create(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t start_lsn)) {
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t record_lsn)) {
#ifdef XTRABACKUP
const byte *start_ptr = ptr;
#endif /* XTRABACKUP */
Expand Down Expand Up @@ -10590,7 +10606,8 @@ const byte *fil_tablespace_redo_create(
#ifdef XTRABACKUP
if (ddl_tracker && redo_catchup_completed)
ddl_tracker->backup_file_op(page_id.space(), MLOG_FILE_CREATE, start_ptr,
static_cast<ulint>(end - start_ptr), start_lsn);
static_cast<ulint>(end - start_ptr),
record_lsn);
#endif /* XTRABACKUP */

if (parse_only) {
Expand Down Expand Up @@ -10678,7 +10695,7 @@ const byte *fil_tablespace_redo_create(
const byte *fil_tablespace_redo_rename(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes,
bool parse_only [[maybe_unused]] IF_XB(, lsn_t start_lsn)) {
bool parse_only [[maybe_unused]] IF_XB(, lsn_t record_lsn)) {
#ifdef XTRABACKUP
const byte *start_ptr = ptr;
#endif /* XTRABACKUP */
Expand Down Expand Up @@ -10713,7 +10730,8 @@ const byte *fil_tablespace_redo_rename(
#ifdef XTRABACKUP
if (ddl_tracker && redo_catchup_completed)
ddl_tracker->backup_file_op(page_id.space(), MLOG_FILE_RENAME, start_ptr,
static_cast<ulint>(end - start_ptr), start_lsn);
static_cast<ulint>(end - start_ptr),
record_lsn);
#endif /* XTRABACKUP */

#ifdef XTRABACKUP
Expand Down Expand Up @@ -10949,12 +10967,12 @@ const byte *fil_tablespace_redo_extend(const byte *ptr, const byte *end,
@param[in] page_id Tablespace Id and first page in file
@param[in] parsed_bytes Number of bytes parsed so far
@param[in] parse_only Don't apply, parse only
@param[in] start_lsn LSN of the redo record
@param[in] record_lsn LSN of the redo record
@return pointer to next redo log record
@retval nullptr if this log record was truncated */
const byte *fil_tablespace_redo_delete(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t start_lsn)) {
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t record_lsn)) {
ut_a(page_id.page_no() == 0);
#ifdef XTRABACKUP
const byte *start_ptr = ptr;
Expand All @@ -10979,7 +10997,8 @@ const byte *fil_tablespace_redo_delete(
#ifdef XTRABACKUP
if (ddl_tracker && redo_catchup_completed)
ddl_tracker->backup_file_op(page_id.space(), MLOG_FILE_DELETE, start_ptr,
static_cast<ulint>(end - start_ptr), start_lsn);
static_cast<ulint>(end - start_ptr),
record_lsn);
#endif /* XTRABACKUP */

if (parse_only) {
Expand Down Expand Up @@ -11669,12 +11688,13 @@ void Tablespace_dirs::open_ibd(const Const_iter &start, const Const_iter &end,
cache and rename ddl will be handled by ddl_tracker we skip loading
duplicate tablespace */
continue;
} else
} 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
18 changes: 11 additions & 7 deletions storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2110,25 +2110,25 @@ inline fil_space_t *fil_space_get_sys_space() {
@param[in] page_id Tablespace Id and first page in file
@param[in] parsed_bytes Number of bytes parsed so far
@param[in] parse_only Don't apply, parse only
@param[in] start_lsn LSN of the redo record
@param[in] record_lsn LSN of the redo record
@return pointer to next redo log record
@retval nullptr if this log record was truncated */
[[nodiscard]] const byte *fil_tablespace_redo_create(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t start_lsn));
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t record_lsn));

/** Redo a tablespace delete.
@param[in] ptr redo log record
@param[in] end end of the redo log buffer
@param[in] page_id Tablespace Id and first page in file
@param[in] parsed_bytes Number of bytes parsed so far
@param[in] parse_only Don't apply, parse only
@param[in] start_lsn LSN of the redo record
@param[in] record_lsn LSN of the redo record
@return pointer to next redo log record
@retval nullptr if this log record was truncated */
[[nodiscard]] const byte *fil_tablespace_redo_delete(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t start_lsn));
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t record_lsn));

/** Redo a tablespace rename.
This function doesn't do anything, simply parses the redo log record.
Expand All @@ -2137,12 +2137,12 @@ This function doesn't do anything, simply parses the redo log record.
@param[in] page_id Tablespace Id and first page in file
@param[in] parsed_bytes Number of bytes parsed so far
@param[in] parse_only Don't apply, parse only
@param[in] start_lsn LSN of the redo record
@param[in] record_lsn LSN of the redo record
@return pointer to next redo log record
@retval nullptr if this log record was truncated */
[[nodiscard]] const byte *fil_tablespace_redo_rename(
const byte *ptr, const byte *end, const page_id_t &page_id,
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t start_lsn));
ulint parsed_bytes, bool parse_only IF_XB(, lsn_t record_lsn));

/** Redo a tablespace extend
@param[in] ptr redo log record
Expand Down Expand Up @@ -2254,6 +2254,10 @@ already be known.
@return DB_SUCCESS if open was successful */
[[nodiscard]] dberr_t fil_tablespace_open_for_recovery(space_id_t space_id);

/** This function is a wrapper to fil_tablespace_open_for_recovery(), used when
* LOCK_DDL_REDUCED is ON
@param[in] path File path
@return DB_SUCCESS if open was successful */
dberr_t fil_open_for_reduced(const std::string &path);

/** Replay a file rename operation for ddl replay.
Expand Down Expand Up @@ -2381,7 +2385,7 @@ inline bool fil_node_t::is_offset_valid(os_offset_t byte_offset) const {
}

/** Frees a space object from the tablespace memory cache.
Closes a tablespaces' files but does not delete them.
Closes a tablespaces files but does not delete them.
There must not be any pending i/o's or flushes on the files.
@param[in] space_id Tablespace ID
@param[in] x_latched Whether the caller holds X-mode space->latch
Expand Down
2 changes: 2 additions & 0 deletions storage/innobase/xtrabackup/src/backup_mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static int original_innodb_buffer_pool_dump_pct;
static bool innodb_buffer_pool_dump;
static bool innodb_buffer_pool_dump_pct;

#ifdef XTRABACKUP
/* This could be either LOCK TABLES FOR BACKUP or LOCK INSTANCE */
static xtrabackup::utils::time backup_lock_start_time =
xtrabackup::utils::INVALID_TIME;
Expand All @@ -152,6 +153,7 @@ static xtrabackup::utils::time backup_lock_end_time =
static xtrabackup::utils::time ftwrl_start_time =
xtrabackup::utils::INVALID_TIME;
static xtrabackup::utils::time ftwrl_end_time = xtrabackup::utils::INVALID_TIME;
#endif /* XTRABACKUP */

MYSQL *xb_mysql_connect() {
MYSQL *connection = mysql_init(NULL);
Expand Down
Loading

0 comments on commit 2a98596

Please sign in to comment.