Commit 67c76704 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12353: Remove MLOG_INDEX_LOAD (innodb_log_optimize_ddl)

NOTE: This may break crash-upgrade from a dataset that was
created with innodb_log_optimize_ddl=ON. Also due to
ROW_FORMAT=COMPRESSED pages, it will be easiest to disallow
crash-upgrade.

It would be more robust to disable the MDEV-12699 logic when
crash-upgrading from old redo log format.

log_optimized_ddl_op: Remove.

fil_space_t::enable_lsn, file_name_t::enable_lsn: Remove.

ddl_tracker_t::optimized_ddl: Remove.

TODO: Remove ddl_tracker
parent f37a29dd
......@@ -352,8 +352,6 @@ typedef std::map<space_id_t,std::string> space_id_to_name_t;
struct ddl_tracker_t {
/** Tablspaces with their ID and name, as they were copied to backup.*/
space_id_to_name_t tables_in_backup;
/** Tablespaces for that optimized DDL without redo log was found.*/
std::set<space_id_t> optimized_ddl;
/** Drop operations found in redo log. */
std::set<space_id_t> drops;
/* For DDL operation found in redo log, */
......@@ -665,30 +663,6 @@ static void backup_file_op_fail(ulint space_id, const byte* flags,
}
/** Callback whenever MLOG_INDEX_LOAD happens.
@param[in] space_id space id to check */
static void backup_optimized_ddl_op(ulint space_id)
{
pthread_mutex_lock(&backup_mutex);
ddl_tracker.optimized_ddl.insert(space_id);
pthread_mutex_unlock(&backup_mutex);
}
/*
Optimized DDL callback at the end of backup that
run with --no-lock. Usually aborts the backup.
*/
static void backup_optimized_ddl_op_fail(ulint space_id) {
msg("DDL tracking : optimized DDL on space %zu", space_id);
if (ddl_tracker.tables_in_backup.find(space_id) != ddl_tracker.tables_in_backup.end()) {
ut_a(opt_no_lock);
msg("ERROR : Optimized DDL operation detected in the late phase of backup."
"Backup is inconsistent. Remove --no-lock option to fix.");
exit(EXIT_FAILURE);
}
}
/*
Retrieve default data directory, to be used with --copy-back.
......@@ -4223,7 +4197,6 @@ static bool xtrabackup_backup_func()
/* copy log file by current position */
log_copy_scanned_lsn = checkpoint_lsn_start;
recv_sys.recovered_lsn = log_copy_scanned_lsn;
log_optimized_ddl_op = backup_optimized_ddl_op;
if (xtrabackup_copy_logfile())
goto fail_before_log_copying_thread_start;
......@@ -4368,7 +4341,6 @@ void backup_fix_ddl(void)
/* Disable further DDL on backed up tables (only needed for --no-lock).*/
pthread_mutex_lock(&backup_mutex);
log_file_op = backup_file_op_fail;
log_optimized_ddl_op = backup_optimized_ddl_op_fail;
pthread_mutex_unlock(&backup_mutex);
DBUG_MARIABACKUP_EVENT("backup_fix_ddl",0);
......@@ -4385,32 +4357,14 @@ void backup_fix_ddl(void)
continue;
}
bool has_optimized_ddl =
ddl_tracker.optimized_ddl.find(id) != ddl_tracker.optimized_ddl.end();
if (ddl_tracker.id_to_name.find(id) == ddl_tracker.id_to_name.end()) {
if (has_optimized_ddl) {
new_tables.insert(name);
}
continue;
}
/* tablespace was affected by DDL. */
const std::string new_name = ddl_tracker.id_to_name[id];
if (new_name != name) {
if (has_optimized_ddl) {
/* table was renamed, but we need a full copy
of it because of optimized DDL. We emulate a drop/create.*/
dropped_tables.insert(name);
new_tables.insert(new_name);
} else {
/* Renamed, and no optimized DDL*/
renamed_tables[name] = new_name;
}
} else if (has_optimized_ddl) {
/* Table was recreated, or optimized DDL ran.
In both cases we need a full copy in the backup.*/
new_tables.insert(name);
renamed_tables[name] = new_name;
}
}
......
......@@ -98,9 +98,6 @@ struct fil_space_t
Protected by log_sys.mutex.
If and only if this is nonzero, the
tablespace will be in named_spaces. */
/** Log sequence number of the latest MLOG_INDEX_LOAD record
that was found while parsing the redo log */
lsn_t enable_lsn;
/** set when an .ibd file is about to be deleted,
or an undo tablespace is about to be truncated.
When this is set following new ops are not allowed:
......
......@@ -112,12 +112,6 @@ bool recv_parse_log_recs(
/** Moves the parsing buffer data left to the buffer start */
void recv_sys_justify_left_parsing_buf();
/** Report optimized DDL operation (without redo log),
corresponding to MLOG_INDEX_LOAD.
@param[in] space_id tablespace identifier
*/
extern void (*log_optimized_ddl_op)(ulint space_id);
/** Report an operation to create, delete, or rename a file during backup.
@param[in] space_id tablespace identifier
@param[in] flags tablespace flags (NULL if not create)
......
......@@ -217,10 +217,6 @@ enum mlog_id_t {
not supported for crash-upgrade to 10.4 or later.) */
MLOG_TRUNCATE = 60,
/** notify that an index tree is being loaded without writing
redo log about individual pages */
MLOG_INDEX_LOAD = 61,
/** write DB_TRX_ID,DB_ROLL_PTR to a clustered index leaf page
of a ROW_FORMAT=COMPRESSED table */
MLOG_ZIP_WRITE_TRX_ID = 62,
......
......@@ -201,22 +201,10 @@ struct file_name_t {
/** FSP_SIZE of tablespace */
ulint size;
/** the log sequence number of the last observed MLOG_INDEX_LOAD
record for the tablespace */
lsn_t enable_lsn;
/** Constructor */
file_name_t(std::string name_, bool deleted) :
name(name_), space(NULL), status(deleted ? DELETED: NORMAL),
size(0), enable_lsn(0) {}
/** Report a MLOG_INDEX_LOAD operation, meaning that
mlog_init for any earlier LSN must be skipped.
@param lsn log sequence number of the MLOG_INDEX_LOAD */
void mlog_index_load(lsn_t lsn)
{
if (enable_lsn < lsn) enable_lsn = lsn;
}
size(0) {}
};
/** Map of dirty tablespaces during recovery */
......@@ -228,12 +216,6 @@ typedef std::map<
static recv_spaces_t recv_spaces;
/** Report optimized DDL operation (without redo log),
corresponding to MLOG_INDEX_LOAD.
@param[in] space_id tablespace identifier
*/
void (*log_optimized_ddl_op)(ulint space_id);
/** Report an operation to create, delete, or rename a file during backup.
@param[in] space_id tablespace identifier
@param[in] flags tablespace flags (NULL if not create)
......@@ -1414,11 +1396,6 @@ recv_parse_or_apply_log_rec_body(
before applying any log records. */
return fil_name_parse(const_cast<byte*>(ptr), end_ptr,
page_id, type, apply);
case MLOG_INDEX_LOAD:
if (end_ptr < ptr + 8) {
return(NULL);
}
return(ptr + 8);
case MLOG_TRUNCATE:
ib::error() << "Cannot crash-upgrade from "
"old-style TRUNCATE TABLE";
......@@ -1931,7 +1908,6 @@ inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
ut_ad(type != MLOG_FILE_NAME);
ut_ad(type != MLOG_DUMMY_RECORD);
ut_ad(type != MLOG_CHECKPOINT);
ut_ad(type != MLOG_INDEX_LOAD);
ut_ad(type != MLOG_TRUNCATE);
std::pair<map::iterator, bool> p= pages.insert(map::value_type
......@@ -2357,7 +2333,6 @@ void recv_apply_hashed_log_recs(bool last_batch)
p++;
continue;
case page_recv_t::RECV_NOT_PROCESSED:
apply:
mtr.start();
mtr.set_log_mode(MTR_LOG_NONE);
if (buf_block_t* block = buf_page_get_gen(
......@@ -2397,34 +2372,6 @@ void recv_apply_hashed_log_recs(bool last_batch)
goto ignore;
}
if (space->enable_lsn) {
do_read:
space->release_for_io();
recs.state = page_recv_t::RECV_NOT_PROCESSED;
goto apply;
}
/* Determine if a tablespace could be
for an internal table for FULLTEXT INDEX.
For those tables, no MLOG_INDEX_LOAD record
used to be written when redo logging was
disabled. Hence, we cannot optimize
away page reads when crash-upgrading
from MariaDB versions before 10.4,
because all the redo log records for
initializing and modifying the page in
the past could be older than the page
in the data file.
The check is too broad, causing all
tables whose names start with FTS_ to
skip the optimization. */
if ((log_sys.log.format & ~log_t::FORMAT_ENCRYPTED)
!= log_t::FORMAT_10_4
&& strstr(space->name, "/FTS_")) {
goto do_read;
}
mtr.start();
mtr.set_log_mode(MTR_LOG_NONE);
buf_block_t* block = buf_page_create(
......@@ -2689,23 +2636,6 @@ recv_report_corrupt_log(
return(true);
}
/** Report a MLOG_INDEX_LOAD operation.
@param[in] space_id tablespace id
@param[in] page_no page number
@param[in] lsn log sequence number */
ATTRIBUTE_COLD static void
recv_mlog_index_load(ulint space_id, ulint page_no, lsn_t lsn)
{
recv_spaces_t::iterator it = recv_spaces.find(space_id);
if (it != recv_spaces.end()) {
it->second.mlog_index_load(lsn);
}
if (log_optimized_ddl_op) {
log_optimized_ddl_op(space_id);
}
}
/** Check whether the number of read redo log blocks exceeds the maximum.
Store last_stored_lsn if the recovery is not in the last phase.
@param[in,out] store whether to store page operations
......@@ -2865,11 +2795,6 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t* store, bool apply)
recv_sys.recovered_lsn);
}
/* fall through */
case MLOG_INDEX_LOAD:
if (type == MLOG_INDEX_LOAD) {
recv_mlog_index_load(space, page_no, old_lsn);
}
/* fall through */
case MLOG_FILE_NAME:
case MLOG_FILE_DELETE:
case MLOG_FILE_CREATE2:
......@@ -3013,9 +2938,6 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t* store, bool apply)
case MLOG_MULTI_REC_END:
/* Found the end mark for the records */
goto loop;
case MLOG_INDEX_LOAD:
recv_mlog_index_load(space, page_no, old_lsn);
break;
case MLOG_FILE_NAME:
case MLOG_FILE_DELETE:
case MLOG_FILE_CREATE2:
......@@ -3546,7 +3468,6 @@ recv_init_crash_recovery_spaces(bool rescan, bool& missing_tablespace)
/* The tablespace was found, and there
are some redo log records for it. */
fil_names_dirty(rs.second.space);
rs.second.space->enable_lsn = rs.second.enable_lsn;
} else if (rs.second.name == "") {
ib::error() << "Missing MLOG_FILE_NAME"
" or MLOG_FILE_DELETE"
......@@ -4103,9 +4024,6 @@ static const char* get_mlog_string(mlog_id_t type)
case MLOG_INIT_FILE_PAGE2:
return("MLOG_INIT_FILE_PAGE2");
case MLOG_INDEX_LOAD:
return("MLOG_INDEX_LOAD");
case MLOG_TRUNCATE:
return("MLOG_TRUNCATE");
......
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