From 06169358d5b2161cd492b248fd5b4ae49474eea0 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Wed, 4 Dec 2024 19:56:46 +0300 Subject: [PATCH] MDEV-35708 lock_rec_get_prev() returns only the first record lock It's supposed that the function gets the previous lock set on a record. But if there are several locks set on a record, it will return only the first one. Continue locks list iteration till the certain lock even if the certain bit in lock bitmap is set. --- storage/innobase/lock/lock0lock.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 1795852ec94d8..f2524c3c15471 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -984,13 +984,14 @@ lock_rec_get_prev( ut_ad(!in_lock->is_table()); const page_id_t id{in_lock->un_member.rec_lock.page_id}; hash_cell_t *cell= lock_sys.hash_get(in_lock->type_mode).cell_get(id.fold()); + lock_t *prev_lock= nullptr; for (lock_t *lock= lock_sys_t::get_first(*cell, id); lock != in_lock; lock= lock_rec_get_next_on_page(lock)) if (lock_rec_get_nth_bit(lock, heap_no)) - return lock; + prev_lock= lock; - return nullptr; + return prev_lock; } /*============= FUNCTIONS FOR ANALYZING RECORD LOCK QUEUE ================*/