summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-07-21 15:59:45 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-07-21 16:03:08 +0300
commitb75563cdfd161e373480949ffa498bd4a8087b12 (patch)
tree9cb4608c7e97cdafb5c9dcfdfa16c4cabb11a5b2
parente26c822aa0a73e62d7a3e4a0915c7bf6cd734978 (diff)
downloadmariadb-git-b75563cdfd161e373480949ffa498bd4a8087b12.tar.gz
MDEV-15880: ASAN heap-use-after-free with innodb_evict_tables_on_commit_debug
trx_update_mod_tables_timestamp(): When implementing innodb_evict_tables_on_commit_debug, do not evict tables on which transactional locks exist. This debug variable was broken since its introduction in commit 947b0b5722117350c83656ee0b23502be59b7d2b.
-rw-r--r--storage/innobase/trx/trx0trx.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index e0d8d44a86e..1d4202b3033 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1295,7 +1295,8 @@ trx_update_mod_tables_timestamp(
dict_table_t* table = it->first;
table->update_time = now;
#ifdef UNIV_DEBUG
- if (preserve_tables || table->get_ref_count()) {
+ if (preserve_tables || table->get_ref_count()
+ || UT_LIST_GET_LEN(table->locks)) {
/* do not evict when committing DDL operations
or if some other transaction is holding the
table handle */
@@ -1304,7 +1305,11 @@ trx_update_mod_tables_timestamp(
/* recheck while holding the mutex that blocks
table->acquire() */
mutex_enter(&dict_sys_mutex);
- if (!table->get_ref_count()) {
+ mutex_enter(&lock_sys.mutex);
+ const bool do_evict = !table->get_ref_count()
+ && !UT_LIST_GET_LEN(table->locks);
+ mutex_exit(&lock_sys.mutex);
+ if (do_evict) {
# if MYSQL_VERSION_ID >= 100405
dict_sys.remove(table, true);
# else