Commit b07920b6 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-27199: Remove FIL_PAGE_FILE_FLUSH_LSN

The only purpose of the field FIL_PAGE_FILE_FLUSH_LSN was to
store the log sequence number for a new ib_logfile0 when the
InnoDB redo log was missing at startup.

Because FIL_PAGE_FILE_FLUSH_LSN no longer serves any purpose,
we will stop updating it. The writes of that field were inherently
risky, because they were not covered by neither the redo log nor
the doublewrite buffer.

Warning: After MDEV-14425 and before this change, users could perform
a clean shutdown of the server, replace the ib_logfile0 with a
0-length file, and expect a valid log file to be created on the
next server startup. After this change, if the FIL_PAGE_FILE_FLUSH_LSN
had ever been updated in the past, the server would still create a
log file in such a scenario, but possibly with an incorrect (too small)
LSN. Users should not manipulate log files directly!
parent 88d9fbb4
......@@ -1382,48 +1382,6 @@ void fil_set_max_space_id_if_bigger(uint32_t max_id)
mysql_mutex_unlock(&fil_system.mutex);
}
/** Write the flushed LSN to the page header of the first page in the
system tablespace.
@param[in] lsn flushed LSN
@return DB_SUCCESS or error number */
dberr_t
fil_write_flushed_lsn(
lsn_t lsn)
{
byte* buf;
ut_ad(!srv_read_only_mode);
if (!fil_system.sys_space->acquire()) {
return DB_ERROR;
}
buf = static_cast<byte*>(aligned_malloc(srv_page_size, srv_page_size));
auto fio = fil_system.sys_space->io(IORequestRead, 0, srv_page_size,
buf);
if (fio.err == DB_SUCCESS) {
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
lsn);
uint32_t fsp_flags = mach_read_from_4(
buf + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
if (fil_space_t::full_crc32(fsp_flags)) {
buf_flush_assign_full_crc32_checksum(buf);
}
fio = fil_system.sys_space->io(IORequestWrite,
0, srv_page_size, buf);
fil_flush_file_spaces();
} else {
fil_system.sys_space->release();
}
aligned_free(buf);
return fio.err;
}
/** Acquire a tablespace reference.
@param id tablespace identifier
@return tablespace
......
......@@ -18229,9 +18229,6 @@ checkpoint_now_set(THD*, st_mysql_sys_var*, void*, const void *save)
(lsn= log_sys.get_lsn(std::memory_order_acquire)))
log_make_checkpoint();
if (dberr_t err= fil_write_flushed_lsn(lsn))
sql_print_warning("innodb_checkpoint_now_set failed: %d", err);
mysql_mutex_lock(&LOCK_global_system_variables);
}
......
......@@ -1593,15 +1593,6 @@ Sets the max tablespace id counter if the given number is bigger than the
previous value. */
void fil_set_max_space_id_if_bigger(uint32_t max_id);
/** Write the flushed LSN to the page header of the first page in the
system tablespace.
@param[in] lsn flushed LSN
@return DB_SUCCESS or error number */
dberr_t
fil_write_flushed_lsn(
lsn_t lsn)
MY_ATTRIBUTE((warn_unused_result));
MY_ATTRIBUTE((warn_unused_result))
/** Delete a tablespace and associated .ibd file.
@param id tablespace identifier
......
......@@ -1032,15 +1032,6 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()
srv_shutdown_lsn = lsn;
if (!srv_read_only_mode) {
dberr_t err = fil_write_flushed_lsn(lsn);
if (err != DB_SUCCESS) {
ib::error() << "Writing flushed lsn " << lsn
<< " failed; error=" << err;
}
}
/* Make some checks that the server really is quiet */
ut_ad(!srv_any_background_activity());
......
......@@ -1181,11 +1181,7 @@ dberr_t srv_start(bool create_new_db)
buf_flush_sync();
const lsn_t lsn{log_sys.get_lsn()};
err = fil_write_flushed_lsn(lsn);
if (err == DB_SUCCESS) {
err = create_log_file_rename(lsn, logfile0);
}
err = create_log_file_rename(log_sys.get_lsn(), logfile0);
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
......@@ -1381,15 +1377,11 @@ dberr_t srv_start(bool create_new_db)
/* Close the redo log file, so that we can replace it */
log_sys.close_file();
err = fil_write_flushed_lsn(lsn);
DBUG_EXECUTE_IF("innodb_log_abort_5",
return(srv_init_abort(DB_ERROR)););
DBUG_PRINT("ib_log", ("After innodb_log_abort_5"));
if (err == DB_SUCCESS) {
err = create_log_file(false, lsn, logfile0);
}
err = create_log_file(false, lsn, logfile0);
if (err == DB_SUCCESS) {
err = create_log_file_rename(lsn, logfile0);
......
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