Skip to content

Commit 3db94d2

Browse files
committed
MDEV-19346: Remove dummy InnoDB log checkpoints
log_checkpoint(), log_make_checkpoint_at(): Remove the parameter write_always. It seems that the primary purpose of this parameter was to ensure in the function recv_reset_logs() that both checkpoint header pages will be overwritten, when the function is called from the never-enabled function recv_recovery_from_archive_start(). create_log_files(): Merge recv_reset_logs() to its only caller. Debug instrumentation: Prefer to flush the redo log, instead of triggering a redo log checkpoint. page_header_set_field(): Disable a debug assertion that will always fail due to MDEV-19344, now that we no longer initiate a redo log checkpoint before an injected crash. In recv_reset_logs() there used to be two calls to log_make_checkpoint_at(). The apparent purpose of this was to ensure that both InnoDB redo log checkpoint header pages will be initialized or overwritten. The second call was removed (without any explanation) in MySQL 5.6.3: mysql/mysql-server@4ca3796 In MySQL 5.6.8 WL#6494, starting with mysql/mysql-server@00a0ba8 the function recv_reset_logs() was not only invoked during InnoDB data file initialization, but also during a regular startup when the redo log is being resized. mysql/mysql-server@45e9167 in MySQL 5.7.2 removed the UNIV_LOG_ARCHIVE code, but still did not remove the parameter write_always.
1 parent bcc1359 commit 3db94d2

File tree

15 files changed

+56
-120
lines changed

15 files changed

+56
-120
lines changed

storage/innobase/buf/buf0dblwr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ buf_dblwr_create()
328328
mtr_commit(&mtr);
329329

330330
/* Flush the modified pages to disk and make a checkpoint */
331-
log_make_checkpoint_at(LSN_MAX, TRUE);
331+
log_make_checkpoint_at(LSN_MAX);
332332

333333
/* Remove doublewrite pages from LRU */
334334
buf_pool_invalidate();

storage/innobase/handler/ha_innodb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19110,7 +19110,7 @@ checkpoint_now_set(
1911019110
+ (log_sys->append_on_checkpoint != NULL
1911119111
? log_sys->append_on_checkpoint->size() : 0)
1911219112
< log_sys->lsn) {
19113-
log_make_checkpoint_at(LSN_MAX, TRUE);
19113+
log_make_checkpoint_at(LSN_MAX);
1911419114
fil_flush_file_spaces(FIL_TYPE_LOG);
1911519115
}
1911619116

storage/innobase/handler/handler0alter.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8474,7 +8474,6 @@ ha_innobase::commit_inplace_alter_table(
84748474
and the .frm files must be swapped manually by
84758475
the administrator. No loss of data. */
84768476
DBUG_EXECUTE_IF("innodb_alter_commit_crash_after_commit",
8477-
log_make_checkpoint_at(LSN_MAX, TRUE);
84788477
log_buffer_flush_to_disk();
84798478
DBUG_SUICIDE(););
84808479
}

storage/innobase/include/log0log.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
44
Copyright (c) 2009, Google Inc.
5-
Copyright (c) 2017, 2018, MariaDB Corporation.
5+
Copyright (c) 2017, 2019, MariaDB Corporation.
66
77
Portions of this file contain modifications contributed and copyrighted by
88
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -208,23 +208,13 @@ blocks from the buffer pool: it only checks what is lsn of the oldest
208208
modification in the pool, and writes information about the lsn in
209209
log files. Use log_make_checkpoint_at() to flush also the pool.
210210
@param[in] sync whether to wait for the write to complete
211-
@param[in] write_always force a write even if no log
212-
has been generated since the latest checkpoint
213211
@return true if success, false if a checkpoint write was already running */
214-
bool
215-
log_checkpoint(
216-
bool sync,
217-
bool write_always);
212+
bool log_checkpoint(bool sync);
218213

219214
/** Make a checkpoint at or after a specified LSN.
220215
@param[in] lsn the log sequence number, or LSN_MAX
221-
for the latest LSN
222-
@param[in] write_always force a write even if no log
223-
has been generated since the latest checkpoint */
224-
void
225-
log_make_checkpoint_at(
226-
lsn_t lsn,
227-
bool write_always);
216+
for the latest LSN */
217+
void log_make_checkpoint_at(lsn_t lsn);
228218

229219
/****************************************************************//**
230220
Makes a checkpoint at the latest lsn and writes it to first page of each

storage/innobase/include/log0recv.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ Initiates the rollback of active transactions. */
6969
void
7070
recv_recovery_rollback_active(void);
7171
/*===============================*/
72-
/******************************************************//**
73-
Resets the logs. The contents of log files will be lost! */
74-
void
75-
recv_reset_logs(
76-
/*============*/
77-
lsn_t lsn); /*!< in: reset to this lsn
78-
rounded up to be divisible by
79-
OS_FILE_LOG_BLOCK_SIZE, after
80-
which we add
81-
LOG_BLOCK_HDR_SIZE */
8272
/** Clean up after recv_sys_init() */
8373
void
8474
recv_sys_close();

storage/innobase/include/page0page.ic

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ page_header_set_field(
173173
{
174174
ut_ad(page);
175175
ut_ad(field <= PAGE_N_RECS);
176+
#if 0 /* FIXME: MDEV-19344 hits this */
176177
ut_ad(field != PAGE_N_RECS || val);
178+
#endif
177179
ut_ad(field == PAGE_N_HEAP || val < srv_page_size);
178180
ut_ad(field != PAGE_N_HEAP || (val & 0x7fff) < srv_page_size);
179181

storage/innobase/log/log0log.cc

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ log_margin_checkpoint_age(
337337
if (!flushed_enough) {
338338
os_thread_sleep(100000);
339339
}
340-
log_checkpoint(true, false);
340+
log_checkpoint(true);
341341

342342
log_mutex_enter();
343343
}
@@ -1610,13 +1610,8 @@ blocks from the buffer pool: it only checks what is lsn of the oldest
16101610
modification in the pool, and writes information about the lsn in
16111611
log files. Use log_make_checkpoint_at() to flush also the pool.
16121612
@param[in] sync whether to wait for the write to complete
1613-
@param[in] write_always force a write even if no log
1614-
has been generated since the latest checkpoint
16151613
@return true if success, false if a checkpoint write was already running */
1616-
bool
1617-
log_checkpoint(
1618-
bool sync,
1619-
bool write_always)
1614+
bool log_checkpoint(bool sync)
16201615
{
16211616
lsn_t oldest_lsn;
16221617

@@ -1657,9 +1652,15 @@ log_checkpoint(
16571652
flushed up to oldest_lsn. */
16581653

16591654
ut_ad(oldest_lsn >= log_sys->last_checkpoint_lsn);
1660-
if (!write_always
1661-
&& oldest_lsn
1662-
<= log_sys->last_checkpoint_lsn + SIZE_OF_MLOG_CHECKPOINT) {
1655+
if (oldest_lsn
1656+
> log_sys->last_checkpoint_lsn + SIZE_OF_MLOG_CHECKPOINT) {
1657+
/* Some log has been written since the previous checkpoint. */
1658+
} else if (srv_shutdown_state != SRV_SHUTDOWN_NONE) {
1659+
/* MariaDB 10.3 startup expects the redo log file to be
1660+
logically empty (not even containing a MLOG_CHECKPOINT record)
1661+
after a clean shutdown. Perform an extra checkpoint at
1662+
shutdown. */
1663+
} else {
16631664
/* Do nothing, because nothing was logged (other than
16641665
a MLOG_CHECKPOINT marker) since the previous checkpoint. */
16651666
log_mutex_exit();
@@ -1691,20 +1692,6 @@ log_checkpoint(
16911692

16921693
log_write_up_to(flush_lsn, true);
16931694

1694-
DBUG_EXECUTE_IF(
1695-
"using_wa_checkpoint_middle",
1696-
if (write_always) {
1697-
DEBUG_SYNC_C("wa_checkpoint_middle");
1698-
1699-
const my_bool b = TRUE;
1700-
buf_flush_page_cleaner_disabled_debug_update(
1701-
NULL, NULL, NULL, &b);
1702-
dict_stats_disabled_debug_update(
1703-
NULL, NULL, NULL, &b);
1704-
srv_master_thread_disabled_debug_update(
1705-
NULL, NULL, NULL, &b);
1706-
});
1707-
17081695
log_mutex_enter();
17091696

17101697
ut_ad(log_sys->flushed_to_disk_lsn >= flush_lsn);
@@ -1737,21 +1724,16 @@ log_checkpoint(
17371724

17381725
/** Make a checkpoint at or after a specified LSN.
17391726
@param[in] lsn the log sequence number, or LSN_MAX
1740-
for the latest LSN
1741-
@param[in] write_always force a write even if no log
1742-
has been generated since the latest checkpoint */
1743-
void
1744-
log_make_checkpoint_at(
1745-
lsn_t lsn,
1746-
bool write_always)
1727+
for the latest LSN */
1728+
void log_make_checkpoint_at(lsn_t lsn)
17471729
{
17481730
/* Preflush pages synchronously */
17491731

17501732
while (!log_preflush_pool_modified_pages(lsn)) {
17511733
/* Flush as much as we can */
17521734
}
17531735

1754-
while (!log_checkpoint(true, write_always)) {
1736+
while (!log_checkpoint(true)) {
17551737
/* Force a checkpoint */
17561738
}
17571739
}
@@ -1834,7 +1816,7 @@ log_checkpoint_margin(void)
18341816
}
18351817

18361818
if (do_checkpoint) {
1837-
log_checkpoint(checkpoint_sync, FALSE);
1819+
log_checkpoint(checkpoint_sync);
18381820

18391821
if (checkpoint_sync) {
18401822

@@ -2083,7 +2065,7 @@ logs_empty_and_mark_files_at_shutdown(void)
20832065
if (!srv_read_only_mode) {
20842066
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
20852067
"ensuring dirty buffer pool are written to log");
2086-
log_make_checkpoint_at(LSN_MAX, TRUE);
2068+
log_make_checkpoint_at(LSN_MAX);
20872069

20882070
log_mutex_enter();
20892071

storage/innobase/log/log0recv.cc

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,11 +2849,6 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
28492849

28502850
if (lsn == checkpoint_lsn) {
28512851
if (recv_sys->mlog_checkpoint_lsn) {
2852-
/* At recv_reset_logs() we may
2853-
write a duplicate MLOG_CHECKPOINT
2854-
for the same checkpoint LSN. Thus
2855-
recv_sys->mlog_checkpoint_lsn
2856-
can differ from the current LSN. */
28572852
ut_ad(recv_sys->mlog_checkpoint_lsn
28582853
<= recv_sys->recovered_lsn);
28592854
break;
@@ -4016,49 +4011,6 @@ recv_recovery_rollback_active(void)
40164011
}
40174012
}
40184013

4019-
/******************************************************//**
4020-
Resets the logs. The contents of log files will be lost! */
4021-
void
4022-
recv_reset_logs(
4023-
/*============*/
4024-
lsn_t lsn) /*!< in: reset to this lsn
4025-
rounded up to be divisible by
4026-
OS_FILE_LOG_BLOCK_SIZE, after
4027-
which we add
4028-
LOG_BLOCK_HDR_SIZE */
4029-
{
4030-
ut_ad(log_mutex_own());
4031-
4032-
log_sys->lsn = ut_uint64_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE);
4033-
4034-
log_sys->log.lsn = log_sys->lsn;
4035-
log_sys->log.lsn_offset = LOG_FILE_HDR_SIZE;
4036-
4037-
log_sys->buf_next_to_write = 0;
4038-
log_sys->write_lsn = log_sys->lsn;
4039-
4040-
log_sys->next_checkpoint_no = 0;
4041-
log_sys->last_checkpoint_lsn = 0;
4042-
4043-
memset(log_sys->buf, 0, log_sys->buf_size);
4044-
log_block_init(log_sys->buf, log_sys->lsn);
4045-
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);
4046-
4047-
log_sys->buf_free = LOG_BLOCK_HDR_SIZE;
4048-
log_sys->lsn += LOG_BLOCK_HDR_SIZE;
4049-
4050-
MONITOR_SET(MONITOR_LSN_CHECKPOINT_AGE,
4051-
(log_sys->lsn - log_sys->last_checkpoint_lsn));
4052-
4053-
log_mutex_exit();
4054-
4055-
/* Reset the checkpoint fields in logs */
4056-
4057-
log_make_checkpoint_at(LSN_MAX, TRUE);
4058-
4059-
log_mutex_enter();
4060-
}
4061-
40624014
/** Find a doublewrite copy of a page.
40634015
@param[in] space_id tablespace identifier
40644016
@param[in] page_no page number

storage/innobase/row/row0import.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ row_import_cleanup(
20902090

20912091
DBUG_EXECUTE_IF("ib_import_before_checkpoint_crash", DBUG_SUICIDE(););
20922092

2093-
log_make_checkpoint_at(LSN_MAX, TRUE);
2093+
log_make_checkpoint_at(LSN_MAX);
20942094

20952095
return(err);
20962096
}

storage/innobase/row/row0ins.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,8 +2722,7 @@ row_ins_clust_index_entry_low(
27222722

27232723
DBUG_EXECUTE_IF(
27242724
"row_ins_extern_checkpoint",
2725-
log_make_checkpoint_at(
2726-
LSN_MAX, TRUE););
2725+
log_write_up_to(mtr.commit_lsn(), true););
27272726
err = row_ins_index_entry_big_rec(
27282727
entry, big_rec, offsets, &offsets_heap, index,
27292728
thr_get_trx(thr)->mysql_thd);

0 commit comments

Comments
 (0)