Skip to content
/ server Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3697,7 +3697,7 @@ static MYSQL_SYSVAR_SIZE_T(buffer_pool_size_max, buf_pool.size_in_bytes_max,
static MYSQL_SYSVAR_UINT(log_write_ahead_size, log_sys.write_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Redo log write size to avoid read-on-write; must be a power of two",
nullptr, nullptr, 512, 512, 4096, 1);
nullptr, nullptr, 512, 512, log_sys.WRITE_SIZE_MAX, 1);

/****************************************************************//**
Gives the file extension of an InnoDB single-table tablespace. */
Expand Down
2 changes: 2 additions & 0 deletions storage/innobase/include/log0log.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ struct log_t
public:
/** current innodb_log_write_ahead_size */
uint write_size;
/** maximum write_size */
static constexpr uint WRITE_SIZE_MAX{4096};
/** format of the redo log: e.g., FORMAT_10_8 */
uint32_t format;
/** whether the memory-mapped interface is enabled for the log */
Expand Down
33 changes: 21 additions & 12 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1247,22 +1247,31 @@ void log_t::clear_mmap() noexcept
ut_ad(write_lsn == get_lsn());
ut_ad(write_lsn == get_flushed_lsn(std::memory_order_relaxed));

if (buf) /* this may be invoked while creating a new database */
{
alignas(16) byte log_block[4096];
const size_t bs{write_size};
if (buf) /* this may be invoked while creating a new database */
{
const size_t bf=
size_t(write_lsn - base_lsn.load(std::memory_order_relaxed));
memcpy_aligned<16>(log_block, buf + (bf & ~(bs - 1)), bs);
}
alignas(16) byte log_block[log_t::WRITE_SIZE_MAX];
const size_t bs{write_size};
{
ut_ad(write_lsn >= first_lsn);
uint64_t bf{write_lsn - first_lsn};
if (bf > capacity())
bf%= capacity();
bf+= START_OFFSET;
const size_t bs_1{bs - 1};
write_lsn_offset= bf & bs_1;
base_lsn.store(write_lsn - write_lsn_offset,
std::memory_order_relaxed);
memcpy_aligned<16>(log_block, buf + (bf & ~uint64_t{bs_1}), bs);
}

close_file(false);
log_mmap= false;
ut_a(attach(log, file_size));
ut_ad(!is_mmap());
close_file(false);
log_mmap= false;
ut_a(attach(log, file_size));
ut_ad(!is_mmap());

memcpy_aligned<16>(buf, log_block, bs);
memcpy_aligned<16>(buf, log_block, bs);
}
}
log_resize_release();
}
Expand Down