@@ -1085,17 +1085,17 @@ log_buffer_switch()
1085
1085
OS_FILE_LOG_BLOCK_SIZE);
1086
1086
1087
1087
if (log_sys->first_in_use ) {
1088
+ log_sys->first_in_use = false ;
1088
1089
ut_ad (log_sys->buf == ut_align (log_sys->buf_ptr ,
1089
1090
OS_FILE_LOG_BLOCK_SIZE));
1090
1091
log_sys->buf += log_sys->buf_size ;
1091
1092
} else {
1093
+ log_sys->first_in_use = true ;
1092
1094
log_sys->buf -= log_sys->buf_size ;
1093
1095
ut_ad (log_sys->buf == ut_align (log_sys->buf_ptr ,
1094
1096
OS_FILE_LOG_BLOCK_SIZE));
1095
1097
}
1096
1098
1097
- log_sys->first_in_use = !log_sys->first_in_use ;
1098
-
1099
1099
/* Copy the last block to new buf */
1100
1100
ut_memcpy (log_sys->buf ,
1101
1101
old_buf + area_end - OS_FILE_LOG_BLOCK_SIZE,
@@ -1235,6 +1235,9 @@ log_write_up_to(
1235
1235
log_group_set_fields (&log_sys->log , log_sys->write_lsn );
1236
1236
1237
1237
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
+
1238
1241
/* Calculate pad_size if needed. */
1239
1242
pad_size = 0 ;
1240
1243
if (write_ahead_size > OS_FILE_LOG_BLOCK_SIZE) {
@@ -1251,12 +1254,9 @@ log_write_up_to(
1251
1254
/* The first block in the unit was initialized
1252
1255
after the last writing.
1253
1256
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);
1260
1260
::memset (write_buf + area_end, 0 , pad_size);
1261
1261
}
1262
1262
}
0 commit comments