Commit 59e8a126 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26879 innodb_evict_tables_on_commit_debug=on makes table creation hang

In commit c5fd9aa5 (MDEV-25919)
an incorrect change to lock_release() was applied.

The setting innodb_evict_tables_on_commit_debug=on should only be
applied to normal transactions, not DDL transactions in the likes of
CREATE TABLE, nor transactions that are holding dict_sys.latch,
such as dict_stats_save().
parent 2a6e0869
SET @save_debug= @@GLOBAL.innodb_evict_tables_on_commit_debug;
SET GLOBAL innodb_evict_tables_on_commit_debug=on;
CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
INSERT INTO t2 VALUES(2);
DROP TABLE t2;
SET GLOBAL innodb_evict_tables_on_commit_debug=@save_debug;
DROP TEMPORARY TABLE t1;
--source include/have_innodb.inc
--source include/have_debug.inc
SET @save_debug= @@GLOBAL.innodb_evict_tables_on_commit_debug;
SET GLOBAL innodb_evict_tables_on_commit_debug=on;
CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
INSERT INTO t2 VALUES(2);
DROP TABLE t2;
SET GLOBAL innodb_evict_tables_on_commit_debug=@save_debug;
DROP TEMPORARY TABLE t1;
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2021, MariaDB Corporation. Copyright (c) 2014, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -3875,11 +3875,12 @@ void lock_release(trx_t *trx) ...@@ -3875,11 +3875,12 @@ void lock_release(trx_t *trx)
{ {
#if defined SAFE_MUTEX && defined UNIV_DEBUG #if defined SAFE_MUTEX && defined UNIV_DEBUG
std::set<table_id_t> to_evict; std::set<table_id_t> to_evict;
if (innodb_evict_tables_on_commit_debug && !trx->is_recovered) if (innodb_evict_tables_on_commit_debug &&
if (!!trx->dict_operation) !trx->is_recovered && !trx->dict_operation &&
for (const auto& p: trx->mod_tables) !trx->dict_operation_lock_mode)
if (!p.first->is_temporary()) for (const auto& p : trx->mod_tables)
to_evict.emplace(p.first->id); if (!p.first->is_temporary())
to_evict.emplace(p.first->id);
#endif #endif
ulint count; ulint count;
...@@ -3942,11 +3943,9 @@ void lock_release(trx_t *trx) ...@@ -3942,11 +3943,9 @@ void lock_release(trx_t *trx)
dict_sys.lock(SRW_LOCK_CALL); dict_sys.lock(SRW_LOCK_CALL);
LockMutexGuard g{SRW_LOCK_CALL}; LockMutexGuard g{SRW_LOCK_CALL};
for (const table_id_t id : to_evict) for (const table_id_t id : to_evict)
{
if (dict_table_t *table= dict_sys.find_table(id)) if (dict_table_t *table= dict_sys.find_table(id))
if (!table->get_ref_count() && !UT_LIST_GET_LEN(table->locks)) if (!table->get_ref_count() && !UT_LIST_GET_LEN(table->locks))
dict_sys.remove(table, true); dict_sys.remove(table, true);
}
dict_sys.unlock(); dict_sys.unlock();
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment