Skip to content

Commit 3c21ecc

Browse files
committed
MDEV-15764 InnoDB may write uninitialized garbage to redo log
log_write_up_to(): Erase the end of the current log block. Simplify the computation of pad_size. log_buffer_switch(): Evaluate a condition only once.
1 parent d9c5a46 commit 3c21ecc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

storage/innobase/log/log0log.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,17 +1085,17 @@ log_buffer_switch()
10851085
OS_FILE_LOG_BLOCK_SIZE);
10861086

10871087
if (log_sys->first_in_use) {
1088+
log_sys->first_in_use = false;
10881089
ut_ad(log_sys->buf == ut_align(log_sys->buf_ptr,
10891090
OS_FILE_LOG_BLOCK_SIZE));
10901091
log_sys->buf += log_sys->buf_size;
10911092
} else {
1093+
log_sys->first_in_use = true;
10921094
log_sys->buf -= log_sys->buf_size;
10931095
ut_ad(log_sys->buf == ut_align(log_sys->buf_ptr,
10941096
OS_FILE_LOG_BLOCK_SIZE));
10951097
}
10961098

1097-
log_sys->first_in_use = !log_sys->first_in_use;
1098-
10991099
/* Copy the last block to new buf */
11001100
ut_memcpy(log_sys->buf,
11011101
old_buf + area_end - OS_FILE_LOG_BLOCK_SIZE,
@@ -1235,6 +1235,9 @@ log_write_up_to(
12351235
log_group_set_fields(&log_sys->log, log_sys->write_lsn);
12361236

12371237
log_mutex_exit();
1238+
/* Erase the end of the last log block. */
1239+
memset(write_buf + end_offset, 0, ~end_offset & OS_FILE_LOG_BLOCK_SIZE);
1240+
12381241
/* Calculate pad_size if needed. */
12391242
pad_size = 0;
12401243
if (write_ahead_size > OS_FILE_LOG_BLOCK_SIZE) {
@@ -1251,12 +1254,9 @@ log_write_up_to(
12511254
/* The first block in the unit was initialized
12521255
after the last writing.
12531256
Needs to be written padded data once. */
1254-
pad_size = write_ahead_size - end_offset_in_unit;
1255-
1256-
if (area_end + pad_size > log_sys->buf_size) {
1257-
pad_size = log_sys->buf_size - area_end;
1258-
}
1259-
1257+
pad_size = std::min(
1258+
ulint(write_ahead_size) - end_offset_in_unit,
1259+
log_sys->buf_size - area_end);
12601260
::memset(write_buf + area_end, 0, pad_size);
12611261
}
12621262
}

0 commit comments

Comments
 (0)