From aa0a9d942c6d4c1e6e66b624c21d00ed0215169c Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 11 Aug 2026 15:39:38 +1000 Subject: [PATCH] [demo] Do not call lock_rec_convert_impl_to_expl if a table S-lock is held In lock_clust_rec_read_check_and_lock there's a test on lock_table_has(trx, index->table, LOCK_X) which if fails would result in a call to lock_rec_convert_impl_to_expl, which 1. has a comment "If an implicit x-lock exists on a record, convert it to an explicit one." that does not apply if a table S-lock is held and 2. does a few things such as looking up the trx_id of the record and find the trx in a global hash trx_sys. In this patch we do the same check for a table S-lock. This could potentially improve the performance of LOCK IN SHARE MODE (TODO: check) --- storage/innobase/lock/lock0lock.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index fb21e5cc9a9fa..caf39037029bb 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -6628,6 +6628,7 @@ lock_clust_rec_read_check_and_lock( trx_t *trx = thr_get_trx(thr); if (lock_table_has(trx, index->table, LOCK_X) + || lock_table_has(trx, index->table, LOCK_S) || heap_no == PAGE_HEAP_NO_SUPREMUM) { } else if (lock_rec_convert_impl_to_expl(trx, *block, rec, index, offsets) == trx