summaryrefslogtreecommitdiff
path: root/storage/innobase/dict
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-08-31 13:54:20 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-08-31 13:54:20 +0300
commit094de71742fbed4d49d38017d56f13100050c747 (patch)
tree32e10fe4ea999fb8e3ccdc18d0e47baeb8c461d6 /storage/innobase/dict
parent6a2cd6f4b406cc3167799f589af1b96c4cd6943c (diff)
downloadmariadb-git-094de71742fbed4d49d38017d56f13100050c747.tar.gz
MDEV-25919 preparation: Various cleanup
que_eval_sql(): Remove the parameter lock_dict. The only caller with lock_dict=true was dict_stats_exec_sql(), which will now explicitly invoke dict_sys.lock() and dict_sys.unlock() by itself. row_import_cleanup(): Do not unnecessarily lock the dictionary. Concurrent access to the table during ALTER TABLE...IMPORT TABLESPACE is prevented by MDL and the fact that there cannot exist any undo log or change buffer records that would refer to the table or tablespace. row_import_for_mysql(): Do not unnecessarily lock the dictionary while accessing fil_system. Thanks to MDL_EXCLUSIVE that was acquired by the SQL layer, only one IMPORT may be in effect for the table name. row_quiesce_set_state(): Do not unnecessarily lock the dictionary. The dict_table_t::quiesce state is documented to be protected by all index latches, which we are acquiring. dict_table_close(): Introduce a simpler variant with fewer parameters. dict_table_close(): Reduce the amount of calls. We can simply invoke dict_table_t::release() on startup or in DDL operations, or when the table is inaccessible. In none of these cases, there is no need to invalidate the InnoDB persistent statistics. pars_info_t::graph_owns_us: Remove (unused). pars_info_free(): Define inline. fts_delete(), trx_t::evict_table(), row_prebuilt_free(), row_rename_table_for_mysql(): Simplify. row_mysql_lock_data_dictionary(): Remove some references; use dict_sys.lock() and dict_sys.unlock() instead. row_mysql_lock_table(): Remove. Use lock_table_for_trx() instead. ha_innobase::check_if_supported_inplace_alter(), row_create_table_for_mysql(): Simply assert dict_sys.sys_tables_exist(). In commit 49e2c8f0a6fefdeac50925f758090d6bd099768d and commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 srv_start() actually guarantees that the system tables will exist, or the server is in read-only mode, or startup will fail. Reviewed by: Thirunarayanan Balathandayuthapani
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r--storage/innobase/dict/dict0crea.cc8
-rw-r--r--storage/innobase/dict/dict0dict.cc38
-rw-r--r--storage/innobase/dict/dict0stats.cc10
-rw-r--r--storage/innobase/dict/dict0stats_bg.cc6
-rw-r--r--storage/innobase/dict/drop.cc6
5 files changed, 39 insertions, 29 deletions
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index c293ab302a3..eafc9bf7814 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -1403,7 +1403,7 @@ dberr_t dict_sys_t::create_or_check_sys_tables()
" ON SYS_FOREIGN (FOR_NAME);\n"
"CREATE INDEX REF_IND"
" ON SYS_FOREIGN (REF_NAME);\n"
- "END;\n", false, trx);
+ "END;\n", trx);
if (UNIV_UNLIKELY(error != DB_SUCCESS))
{
tablename= SYS_TABLE[SYS_FOREIGN].data();
@@ -1425,7 +1425,7 @@ err_exit:
" FOR_COL_NAME CHAR, REF_COL_NAME CHAR);\n"
"CREATE UNIQUE CLUSTERED INDEX ID_IND"
" ON SYS_FOREIGN_COLS (ID, POS);\n"
- "END;\n", false, trx);
+ "END;\n", trx);
if (UNIV_UNLIKELY(error != DB_SUCCESS))
{
tablename= SYS_TABLE[SYS_FOREIGN_COLS].data();
@@ -1440,7 +1440,7 @@ err_exit:
"SYS_VIRTUAL(TABLE_ID BIGINT,POS INT,BASE_POS INT);\n"
"CREATE UNIQUE CLUSTERED INDEX BASE_IDX"
" ON SYS_VIRTUAL(TABLE_ID, POS, BASE_POS);\n"
- "END;\n", false, trx);
+ "END;\n", trx);
if (UNIV_UNLIKELY(error != DB_SUCCESS))
{
tablename= SYS_TABLE[SYS_VIRTUAL].data();
@@ -1504,7 +1504,7 @@ dict_foreign_eval_sql(
dberr_t error;
FILE* ef = dict_foreign_err_file;
- error = que_eval_sql(info, sql, FALSE, trx);
+ error = que_eval_sql(info, sql, trx);
if (error == DB_DUPLICATE_KEY) {
mysql_mutex_lock(&dict_foreign_err_mutex);
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 400cda111fe..13b71c9a8b6 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -299,6 +299,25 @@ dict_table_try_drop_aborted_and_unlock(
}
}
+/** Decrement the count of open handles */
+void dict_table_close(dict_table_t *table)
+{
+ if (dict_stats_is_persistent_enabled(table) &&
+ strchr(table->name.m_name, '/'))
+ {
+ dict_sys.freeze(SRW_LOCK_CALL);
+ if (table->release())
+ {
+ table->stats_mutex_lock();
+ dict_stats_deinit(table);
+ table->stats_mutex_unlock();
+ }
+ dict_sys.unfreeze();
+ }
+ else
+ table->release();
+}
+
/** Decrements the count of open handles of a table.
@param[in,out] table table
@param[in] dict_locked data dictionary locked
@@ -4223,12 +4242,7 @@ void dict_set_encrypted_by_space(const fil_space_t* space)
/**********************************************************************//**
Flags an index corrupted both in the data dictionary cache
and in the SYS_INDEXES */
-void
-dict_set_corrupted(
-/*===============*/
- dict_index_t* index, /*!< in/out: index */
- trx_t* trx, /*!< in/out: transaction */
- const char* ctx) /*!< in: context */
+void dict_set_corrupted(dict_index_t *index, const char *ctx, bool dict_locked)
{
mem_heap_t* heap;
mtr_t mtr;
@@ -4238,10 +4252,9 @@ dict_set_corrupted(
byte* buf;
const char* status;
btr_cur_t cursor;
- bool locked = RW_X_LATCH == trx->dict_operation_lock_mode;
- if (!locked) {
- row_mysql_lock_data_dictionary(trx);
+ if (!dict_locked) {
+ dict_sys.lock(SRW_LOCK_CALL);
}
ut_ad(dict_sys.locked());
@@ -4311,14 +4324,13 @@ fail:
}
mtr_commit(&mtr);
- mem_heap_empty(heap);
+ mem_heap_free(heap);
ib::error() << status << " corruption of " << index->name
<< " in table " << index->table->name << " in " << ctx;
- mem_heap_free(heap);
func_exit:
- if (!locked) {
- row_mysql_unlock_data_dictionary(trx);
+ if (!dict_locked) {
+ dict_sys.unlock();
}
}
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index ee72d7db3cd..9c4d87f3fea 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -533,13 +533,13 @@ dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char* sql, trx_t *trx)
}
if (trx)
- return que_eval_sql(pinfo, sql, FALSE, trx);
+ return que_eval_sql(pinfo, sql, trx);
trx= trx_create();
trx_start_internal(trx);
trx->dict_operation_lock_mode= RW_X_LATCH;
- dberr_t err= que_eval_sql(pinfo, sql, FALSE, trx);
+ dberr_t err= que_eval_sql(pinfo, sql, trx);
if (err == DB_SUCCESS)
trx->commit();
@@ -3255,7 +3255,7 @@ dict_stats_fetch_from_ps(
"fetch_index_stats_step",
dict_stats_fetch_index_stats_step,
&index_fetch_arg);
-
+ dict_sys.lock(SRW_LOCK_CALL); /* FIXME: remove this */
ret = que_eval_sql(pinfo,
"PROCEDURE FETCH_STATS () IS\n"
"found INT;\n"
@@ -3309,9 +3309,9 @@ dict_stats_fetch_from_ps(
"END LOOP;\n"
"CLOSE index_stats_cur;\n"
- "END;",
- TRUE, trx);
+ "END;", trx);
/* pinfo is freed by que_eval_sql() */
+ dict_sys.unlock();
trx_commit_for_mysql(trx);
diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc
index 209a2f33ba9..23b00bb8e23 100644
--- a/storage/innobase/dict/dict0stats_bg.cc
+++ b/storage/innobase/dict/dict0stats_bg.cc
@@ -348,7 +348,7 @@ next_table_id:
ut_ad(!table->is_temporary());
if (!table->is_accessible()) {
- dict_table_close(table, TRUE, FALSE);
+ table->release();
no_table:
dict_sys.unlock();
goto next_table_id;
@@ -382,12 +382,10 @@ no_table:
}
dict_sys.lock(SRW_LOCK_CALL);
-
table->stats_bg_flag = BG_STAT_NONE;
-
dict_table_close(table, TRUE, FALSE);
-
dict_sys.unlock();
+
return ret;
}
diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc
index bb0af50c4c2..f837798ab8f 100644
--- a/storage/innobase/dict/drop.cc
+++ b/storage/innobase/dict/drop.cc
@@ -108,7 +108,7 @@ dberr_t trx_t::drop_table_foreign(const table_name_t &name)
" DELETE FROM SYS_FOREIGN WHERE ID=fid;\n"
"END LOOP;\n"
"CLOSE fk;\n"
- "END;\n", FALSE, this);
+ "END;\n", this);
}
/** Try to drop the statistics for a persistent table.
@@ -182,7 +182,7 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
"BEGIN\n"
"DELETE FROM SYS_VIRTUAL"
" WHERE TABLE_ID=:id;\n"
- "END;\n", FALSE, this))
+ "END;\n", this))
return err;
}
@@ -224,7 +224,7 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
"END LOOP;\n"
"CLOSE idx;\n"
- "END;\n", FALSE, this);
+ "END;\n", this);
}
/** Commit the transaction, possibly after drop_table().