From b36da48ad364ee1ea9cfe6bfb46ba89c99051106 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 27 Mar 2018 16:05:50 +0400 Subject: [PATCH] MDEV-15612 - Latching violation in trx_roll_must_shutdown recv_sys_t::mutex and rw_trx_hash_elementi_t::mutex were acquired in reverse (to recorded) order. Fixed by releasing recv_sys_t::mutex, before iterating rw_trx_hash. Statistics gathering doesn't really need recv_sys_t::mutex protection, since it is always done in one thread (trx_roll_crash_recv_trx) and thus it can't go wrong. --- storage/innobase/trx/trx0roll.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index c729407ee6e77..13bbbb2ebd1c5 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -737,8 +737,10 @@ trx_roll_must_shutdown() ib_time_t time = ut_time(); mutex_enter(&recv_sys->mutex); + bool report = recv_sys->report(time); + mutex_exit(&recv_sys->mutex); - if (recv_sys->report(time)) { + if (report) { trx_roll_count_callback_arg arg; /* Get number of recovered active transactions and number of @@ -752,8 +754,6 @@ trx_roll_must_shutdown() sd_notifyf(0, "STATUS=To roll back: " UINT32PF " transactions," " " UINT64PF " rows", arg.n_trx, arg.n_rows); } - - mutex_exit(&recv_sys->mutex); return false; }