Skip to content

Commit 9ea7f71

Browse files
committed
MDEV-34909 DDL hang during SET GLOBAL innodb_log_file_size on PMEM
log_t::persist(): Add a parameter holding_latch to specify whether the caller is already holding exclusive log_sys.latch, like log_write_and_flush() always is.
1 parent cb83ae2 commit 9ea7f71

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

storage/innobase/include/log0log.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,9 @@ struct log_t
452452

453453
#ifdef HAVE_PMEM
454454
/** Persist the log.
455-
@param lsn desired new value of flushed_to_disk_lsn */
456-
inline void persist(lsn_t lsn) noexcept;
455+
@param lsn desired new value of flushed_to_disk_lsn
456+
@param holding_latch whether the caller is holding exclusive latch */
457+
void persist(lsn_t lsn, bool holding_latch) noexcept;
457458
#endif
458459

459460
bool check_for_checkpoint() const

storage/innobase/log/log0log.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,21 +730,22 @@ static size_t log_pad(lsn_t lsn, size_t pad, byte *begin, byte *extra)
730730
#endif
731731

732732
#ifdef HAVE_PMEM
733-
/** Persist the log.
734-
@param lsn desired new value of flushed_to_disk_lsn */
735-
inline void log_t::persist(lsn_t lsn) noexcept
733+
void log_t::persist(lsn_t lsn, bool holding_latch) noexcept
736734
{
737735
ut_ad(is_pmem());
738736
ut_ad(!write_lock.is_owner());
739737
ut_ad(!flush_lock.is_owner());
738+
#ifdef LOG_LATCH_DEBUG
739+
ut_ad(holding_latch == latch_have_wr());
740+
#endif
740741

741742
lsn_t old= flushed_to_disk_lsn.load(std::memory_order_relaxed);
742743

743744
if (old >= lsn)
744745
return;
745746

746-
const lsn_t resizing{resize_in_progress()};
747-
if (UNIV_UNLIKELY(resizing))
747+
const bool latching{!holding_latch && resize_in_progress()};
748+
if (UNIV_UNLIKELY(latching))
748749
latch.rd_lock(SRW_LOCK_CALL);
749750
const size_t start(calc_lsn_offset(old));
750751
const size_t end(calc_lsn_offset(lsn));
@@ -771,7 +772,7 @@ inline void log_t::persist(lsn_t lsn) noexcept
771772
DBUG_EXECUTE_IF("crash_after_log_write_upto", DBUG_SUICIDE(););
772773
}
773774

774-
if (UNIV_UNLIKELY(resizing))
775+
if (UNIV_UNLIKELY(latching))
775776
latch.rd_unlock();
776777
}
777778
#endif
@@ -976,7 +977,7 @@ void log_write_up_to(lsn_t lsn, bool durable,
976977
{
977978
ut_ad(!callback);
978979
if (durable)
979-
log_sys.persist(lsn);
980+
log_sys.persist(lsn, false);
980981
return;
981982
}
982983
#endif
@@ -1043,7 +1044,7 @@ ATTRIBUTE_COLD void log_write_and_flush()
10431044
}
10441045
#ifdef HAVE_PMEM
10451046
else
1046-
log_sys.persist(log_sys.get_lsn());
1047+
log_sys.persist(log_sys.get_lsn(), true);
10471048
#endif
10481049
}
10491050

0 commit comments

Comments
 (0)