Skip to content

Commit b07920b

Browse files
committed
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!
1 parent 88d9fbb commit b07920b

File tree

5 files changed

+2
-73
lines changed

5 files changed

+2
-73
lines changed

Diff for: storage/innobase/fil/fil0fil.cc

-42
Original file line numberDiff line numberDiff line change
@@ -1382,48 +1382,6 @@ void fil_set_max_space_id_if_bigger(uint32_t max_id)
13821382
mysql_mutex_unlock(&fil_system.mutex);
13831383
}
13841384

1385-
/** Write the flushed LSN to the page header of the first page in the
1386-
system tablespace.
1387-
@param[in] lsn flushed LSN
1388-
@return DB_SUCCESS or error number */
1389-
dberr_t
1390-
fil_write_flushed_lsn(
1391-
lsn_t lsn)
1392-
{
1393-
byte* buf;
1394-
ut_ad(!srv_read_only_mode);
1395-
1396-
if (!fil_system.sys_space->acquire()) {
1397-
return DB_ERROR;
1398-
}
1399-
1400-
buf = static_cast<byte*>(aligned_malloc(srv_page_size, srv_page_size));
1401-
1402-
auto fio = fil_system.sys_space->io(IORequestRead, 0, srv_page_size,
1403-
buf);
1404-
1405-
if (fio.err == DB_SUCCESS) {
1406-
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
1407-
lsn);
1408-
1409-
uint32_t fsp_flags = mach_read_from_4(
1410-
buf + FSP_HEADER_OFFSET + FSP_SPACE_FLAGS);
1411-
1412-
if (fil_space_t::full_crc32(fsp_flags)) {
1413-
buf_flush_assign_full_crc32_checksum(buf);
1414-
}
1415-
1416-
fio = fil_system.sys_space->io(IORequestWrite,
1417-
0, srv_page_size, buf);
1418-
fil_flush_file_spaces();
1419-
} else {
1420-
fil_system.sys_space->release();
1421-
}
1422-
1423-
aligned_free(buf);
1424-
return fio.err;
1425-
}
1426-
14271385
/** Acquire a tablespace reference.
14281386
@param id tablespace identifier
14291387
@return tablespace

Diff for: storage/innobase/handler/ha_innodb.cc

-3
Original file line numberDiff line numberDiff line change
@@ -18229,9 +18229,6 @@ checkpoint_now_set(THD*, st_mysql_sys_var*, void*, const void *save)
1822918229
(lsn= log_sys.get_lsn(std::memory_order_acquire)))
1823018230
log_make_checkpoint();
1823118231

18232-
if (dberr_t err= fil_write_flushed_lsn(lsn))
18233-
sql_print_warning("innodb_checkpoint_now_set failed: %d", err);
18234-
1823518232
mysql_mutex_lock(&LOCK_global_system_variables);
1823618233
}
1823718234

Diff for: storage/innobase/include/fil0fil.h

-9
Original file line numberDiff line numberDiff line change
@@ -1593,15 +1593,6 @@ Sets the max tablespace id counter if the given number is bigger than the
15931593
previous value. */
15941594
void fil_set_max_space_id_if_bigger(uint32_t max_id);
15951595

1596-
/** Write the flushed LSN to the page header of the first page in the
1597-
system tablespace.
1598-
@param[in] lsn flushed LSN
1599-
@return DB_SUCCESS or error number */
1600-
dberr_t
1601-
fil_write_flushed_lsn(
1602-
lsn_t lsn)
1603-
MY_ATTRIBUTE((warn_unused_result));
1604-
16051596
MY_ATTRIBUTE((warn_unused_result))
16061597
/** Delete a tablespace and associated .ibd file.
16071598
@param id tablespace identifier

Diff for: storage/innobase/log/log0log.cc

-9
Original file line numberDiff line numberDiff line change
@@ -1032,15 +1032,6 @@ ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()
10321032

10331033
srv_shutdown_lsn = lsn;
10341034

1035-
if (!srv_read_only_mode) {
1036-
dberr_t err = fil_write_flushed_lsn(lsn);
1037-
1038-
if (err != DB_SUCCESS) {
1039-
ib::error() << "Writing flushed lsn " << lsn
1040-
<< " failed; error=" << err;
1041-
}
1042-
}
1043-
10441035
/* Make some checks that the server really is quiet */
10451036
ut_ad(!srv_any_background_activity());
10461037

Diff for: storage/innobase/srv/srv0start.cc

+2-10
Original file line numberDiff line numberDiff line change
@@ -1181,11 +1181,7 @@ dberr_t srv_start(bool create_new_db)
11811181

11821182
buf_flush_sync();
11831183

1184-
const lsn_t lsn{log_sys.get_lsn()};
1185-
err = fil_write_flushed_lsn(lsn);
1186-
if (err == DB_SUCCESS) {
1187-
err = create_log_file_rename(lsn, logfile0);
1188-
}
1184+
err = create_log_file_rename(log_sys.get_lsn(), logfile0);
11891185

11901186
if (err != DB_SUCCESS) {
11911187
return(srv_init_abort(err));
@@ -1381,15 +1377,11 @@ dberr_t srv_start(bool create_new_db)
13811377
/* Close the redo log file, so that we can replace it */
13821378
log_sys.close_file();
13831379

1384-
err = fil_write_flushed_lsn(lsn);
1385-
13861380
DBUG_EXECUTE_IF("innodb_log_abort_5",
13871381
return(srv_init_abort(DB_ERROR)););
13881382
DBUG_PRINT("ib_log", ("After innodb_log_abort_5"));
13891383

1390-
if (err == DB_SUCCESS) {
1391-
err = create_log_file(false, lsn, logfile0);
1392-
}
1384+
err = create_log_file(false, lsn, logfile0);
13931385

13941386
if (err == DB_SUCCESS) {
13951387
err = create_log_file_rename(lsn, logfile0);

0 commit comments

Comments
 (0)