From a524ec5951d68cec7ef6228093ea1b1993a3243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Apr 2025 10:33:22 +0300 Subject: [PATCH] MDEV-36587 InnoDB uses too much memory log_t::clear_mmap(): Do not modify buf_size; we may have file_size==0 here during bootstrap. log_t::set_recovered(): If we are writing to a memory-mapped log, update log_sys.buf_size to the record payload area of log_sys.buf. This fixes up commit acd071f599f416ddb4821dec485c4d912844213f (MDEV-21923). --- storage/innobase/log/log0log.cc | 5 ++--- storage/innobase/log/log0recv.cc | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 22994e389c9..64ca9e6fff6 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -1237,11 +1237,10 @@ void log_t::clear_mmap() noexcept #ifdef HAVE_PMEM if (!is_opened()) { - latch.wr_lock(SRW_LOCK_CALL); + ut_d(latch.wr_lock(SRW_LOCK_CALL)); ut_ad(!resize_in_progress()); ut_ad(get_lsn() == get_flushed_lsn(std::memory_order_relaxed)); - buf_size= unsigned(std::min(capacity(), buf_size_max)); - latch.wr_unlock(); + ut_d(latch.wr_unlock()); return; } #endif diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 30b99ea0bc7..4162f60fee5 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -4590,7 +4590,10 @@ inline void log_t::set_recovered() noexcept } #ifdef HAVE_PMEM else + { + buf_size= unsigned(std::min(capacity(), buf_size_max)); mprotect(buf, size_t(file_size), PROT_READ | PROT_WRITE); + } #endif }