diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-01 17:05:20 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-03-01 17:05:42 +0200 |
commit | 35903da4f8b1d9a430061f97811a3eeeffa7efe5 (patch) | |
tree | 13f655dc817e9e3e572b576fc6440d515961a923 | |
parent | 3c4a98c9a18229b2ffcf65d29f2e8bdf8003fc75 (diff) | |
download | mariadb-git-bb-10.6-MDEV-24789.tar.gz |
fixup 1c21a9d27ab568486d55e0b49a78e12c04178e6fbb-10.6-MDEV-24789
lock_release_autoinc_locks(): Avoid duplicated mutex acquisition
lock_sys_t::cancel(): Fix a race. The lock may already have been
canceled by another thread by the time we acquire the latch.
-rw-r--r-- | storage/innobase/lock/lock0lock.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 791f77f583d..223783a11bc 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -5376,11 +5376,12 @@ static void lock_release_autoinc_locks(trx_t *trx, bool owns_wait_mutex) (ib_vector_get(autoinc_locks, size - 1)); ut_ad(lock->type_mode == (LOCK_AUTO_INC | LOCK_TABLE)); dict_table_t *table= lock->un_member.tab_lock.table; - /* The mutex is only necessary if !lock_sys.is_writer() */ - table->lock_mutex_lock(); + if (!owns_wait_mutex) + table->lock_mutex_lock(); lock_table_dequeue(lock, owns_wait_mutex); lock_trx_table_locks_remove(lock); - table->lock_mutex_unlock(); + if (!owns_wait_mutex) + table->lock_mutex_unlock(); } } @@ -5424,7 +5425,8 @@ void lock_sys_t::cancel(trx_t *trx, lock_t *lock) { dict_table_t *table= lock->un_member.tab_lock.table; table->lock_mutex_lock(); - lock_cancel_waiting_and_release(lock); + if (lock->is_waiting()) + lock_cancel_waiting_and_release(lock); table->lock_mutex_unlock(); } else @@ -5433,7 +5435,8 @@ void lock_sys_t::cancel(trx_t *trx, lock_t *lock) (lock_sys.hash_get(lock->type_mode).cell_get (lock->un_member.rec_lock.page_id.fold())); latch->acquire(); - lock_cancel_waiting_and_release(lock); + if (lock->is_waiting()) + lock_cancel_waiting_and_release(lock); latch->release(); } } |