summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2021-05-04 14:49:31 +0300
committerNikita Malyavin <nikitamalyavin@gmail.com>2021-05-04 14:49:31 +0300
commita8a925dd22ae00494cc9ffdc1ff68906106a408c (patch)
treea857c565a22ec7f6f41d3efa72053a726a346af2 /storage/innobase
parent2820f30dde3148df71e1d748ac705d98d60e0787 (diff)
parent72fa9dabadb4b0011f483ccbf1ef59e62d0ef1e0 (diff)
downloadmariadb-git-a8a925dd22ae00494cc9ffdc1ff68906106a408c.tar.gz
Merge branch bb-10.2-release into bb-10.3-release
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/dict/dict0dict.cc6
-rw-r--r--storage/innobase/fil/fil0fil.cc17
-rw-r--r--storage/innobase/handler/ha_innodb.cc52
-rw-r--r--storage/innobase/handler/i_s.cc3
-rw-r--r--storage/innobase/include/dict0mem.h5
-rw-r--r--storage/innobase/include/srv0srv.h10
-rw-r--r--storage/innobase/include/trx0trx.h4
-rw-r--r--storage/innobase/lock/lock0wait.cc33
-rw-r--r--storage/innobase/row/row0purge.cc20
-rw-r--r--storage/innobase/row/row0vers.cc1
-rw-r--r--storage/innobase/srv/srv0srv.cc17
-rw-r--r--storage/innobase/trx/trx0roll.cc3
-rw-r--r--storage/innobase/trx/trx0trx.cc13
13 files changed, 152 insertions, 32 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 1f05eb80e5d..10b878c0e49 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -6587,3 +6587,9 @@ dict_table_t::get_overflow_field_local_len() const
/* up to MySQL 5.1: store a 768-byte prefix locally */
return BTR_EXTERN_FIELD_REF_SIZE + DICT_ANTELOPE_MAX_INDEX_COL_LEN;
}
+
+bool dict_table_t::is_stats_table() const
+{
+ return !strcmp(name.m_name, TABLE_STATS_NAME) ||
+ !strcmp(name.m_name, INDEX_STATS_NAME);
+}
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 9b91fdd879f..3d4d65eccfd 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
-Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2020, MariaDB Corporation.
+Copyright (c) 1995, 2021, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2014, 2021, MariaDB Corporation.
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
@@ -3777,7 +3777,7 @@ fil_ibd_load(
space = fil_space_get_by_id(space_id);
mutex_exit(&fil_system.mutex);
- if (space != NULL) {
+ if (space) {
/* Compare the filename we are trying to open with the
filename from the first node of the tablespace we opened
previously. Fail if it is different. */
@@ -3789,8 +3789,8 @@ fil_ibd_load(
<< "' with space ID " << space->id
<< ". Another data file called " << node->name
<< " exists with the same space ID.";
- space = NULL;
- return(FIL_LOAD_ID_CHANGED);
+ space = NULL;
+ return(FIL_LOAD_ID_CHANGED);
}
return(FIL_LOAD_OK);
}
@@ -3827,13 +3827,6 @@ fil_ibd_load(
os_offset_t minimum_size;
case DB_SUCCESS:
if (file.space_id() != space_id) {
- ib::info()
- << "Ignoring data file '"
- << file.filepath()
- << "' with space ID " << file.space_id()
- << ", since the redo log references "
- << file.filepath() << " with space ID "
- << space_id << ".";
return(FIL_LOAD_ID_CHANGED);
}
/* Get and test the file size. */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index c5b65160827..2f02fa31c98 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5270,13 +5270,19 @@ ha_innobase::index_type(
{
dict_index_t* index = innobase_get_index(keynr);
- if (index && index->type & DICT_FTS) {
+ if (!index) {
+ return "Corrupted";
+ }
+
+ if (index->type & DICT_FTS) {
return("FULLTEXT");
- } else if (dict_index_is_spatial(index)) {
+ }
+
+ if (dict_index_is_spatial(index)) {
return("SPATIAL");
- } else {
- return("BTREE");
}
+
+ return("BTREE");
}
/****************************************************************//**
@@ -18835,6 +18841,33 @@ innodb_log_checksums_update(THD* thd, st_mysql_sys_var*, void* var_ptr,
thd, *static_cast<const my_bool*>(save));
}
+#ifdef UNIV_DEBUG
+static
+void
+innobase_debug_sync_callback(srv_slot_t *slot, const void *value)
+{
+ const char *value_str = *static_cast<const char* const*>(value);
+ size_t len = strlen(value_str) + 1;
+
+
+ // One allocation for list node object and value.
+ void *buf = ut_malloc_nokey(sizeof(srv_slot_t::debug_sync_t) + len-1);
+ srv_slot_t::debug_sync_t *sync = new(buf) srv_slot_t::debug_sync_t();
+ strcpy(sync->str, value_str);
+
+ rw_lock_x_lock(&slot->debug_sync_lock);
+ UT_LIST_ADD_LAST(slot->debug_sync, sync);
+ rw_lock_x_unlock(&slot->debug_sync_lock);
+}
+static
+void
+innobase_debug_sync_set(THD *thd, st_mysql_sys_var*, void *, const void *value)
+{
+ srv_for_each_thread(SRV_WORKER, innobase_debug_sync_callback, value);
+ srv_for_each_thread(SRV_PURGE, innobase_debug_sync_callback, value);
+}
+#endif
+
static SHOW_VAR innodb_status_variables_export[]= {
{"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
{NullS, NullS, SHOW_LONG}
@@ -20399,6 +20432,16 @@ static MYSQL_SYSVAR_BOOL(debug_force_scrubbing,
0,
"Perform extra scrubbing to increase test exposure",
NULL, NULL, FALSE);
+
+char *innobase_debug_sync;
+static MYSQL_SYSVAR_STR(debug_sync, innobase_debug_sync,
+ PLUGIN_VAR_NOCMDARG,
+ "debug_sync for innodb purge threads. "
+ "Use it to set up sync points for all purge threads "
+ "at once. The commands will be applied sequentially at"
+ " the beginning of purging the next undo record.",
+ NULL,
+ innobase_debug_sync_set, NULL);
#endif /* UNIV_DEBUG */
static MYSQL_SYSVAR_BOOL(encrypt_temporary_tables, innodb_encrypt_temporary_tables,
@@ -20612,6 +20655,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(background_scrub_data_check_interval),
#ifdef UNIV_DEBUG
MYSQL_SYSVAR(debug_force_scrubbing),
+ MYSQL_SYSVAR(debug_sync),
#endif
MYSQL_SYSVAR(buf_dump_status_frequency),
MYSQL_SYSVAR(background_thread),
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index d8cb0b67ab5..206756ec09b 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -2880,7 +2880,8 @@ i_s_fts_deleted_generic_fill(
if (!user_table) {
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0);
- } else if (!dict_table_has_fts_index(user_table)) {
+ } else if (!dict_table_has_fts_index(user_table)
+ || !user_table->is_readable()) {
dict_table_close(user_table, FALSE, FALSE);
rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0);
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 40c343652fb..a4ac79a0d6d 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -2115,6 +2115,11 @@ public:
return true;
return false;
}
+
+ /** Check whether the table name is same as mysql/innodb_stats_table
+ or mysql/innodb_index_stats.
+ @return true if the table name is same as stats table */
+ bool is_stats_table() const;
};
inline void dict_index_t::set_modified(mtr_t& mtr) const
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 6aa079676a0..ae05d45e257 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -1119,6 +1119,16 @@ struct srv_slot_t{
to do */
que_thr_t* thr; /*!< suspended query thread
(only used for user threads) */
+#ifdef UNIV_DEBUG
+ struct debug_sync_t {
+ UT_LIST_NODE_T(debug_sync_t)
+ debug_sync_list;
+ char str[1];
+ };
+ UT_LIST_BASE_NODE_T(debug_sync_t)
+ debug_sync;
+ rw_lock_t debug_sync_lock;
+#endif
};
#ifdef UNIV_DEBUG
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index c1572a0d07f..7cd11bf5496 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -1119,6 +1119,10 @@ public:
ut_ad(old_n_ref > 0);
}
+ /** @return whether the table has lock on
+ mysql.innodb_table_stats and mysql.innodb_index_stats */
+ bool has_stats_table_lock() const;
+
/** Free the memory to trx_pools */
void free();
diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc
index 90fe1ccd626..3291198e376 100644
--- a/storage/innobase/lock/lock0wait.cc
+++ b/storage/innobase/lock/lock0wait.cc
@@ -192,28 +192,33 @@ wsrep_is_BF_lock_timeout(
const trx_t* trx,
bool locked = true)
{
- if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)
- && trx->error_state != DB_DEADLOCK) {
- ib::info() << "WSREP: BF lock wait long for trx:" << ib::hex(trx->id)
+ bool long_wait= (trx->error_state != DB_DEADLOCK &&
+ trx->is_wsrep() &&
+ wsrep_thd_is_BF(trx->mysql_thd, false));
+ bool was_wait= true;
+
+ DBUG_EXECUTE_IF("wsrep_instrument_BF_lock_wait",
+ was_wait=false; long_wait=true;);
+
+ if (long_wait) {
+ ib::info() << "WSREP: BF lock wait long for trx:" << trx->id
<< " query: " << wsrep_thd_query(trx->mysql_thd);
- if (!locked) {
+
+ if (!locked)
lock_mutex_enter();
- }
ut_ad(lock_mutex_own());
trx_print_latched(stderr, trx, 3000);
+ /* Note this will release lock_sys mutex */
+ lock_print_info_all_transactions(stderr);
- if (!locked) {
- lock_mutex_exit();
- }
+ if (locked)
+ lock_mutex_enter();
- srv_print_innodb_monitor = TRUE;
- srv_print_innodb_lock_monitor = TRUE;
- os_event_set(srv_monitor_event);
- return true;
- }
- return false;
+ return was_wait;
+ } else
+ return false;
}
#endif /* WITH_WSREP */
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index 6a7f5921aa3..e57a63bc8e2 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -46,6 +46,7 @@ Created 3/14/1997 Heikki Tuuri
#include "handler.h"
#include "ha_innodb.h"
#include "fil0fil.h"
+#include "debug_sync.h"
/*************************************************************************
IMPORTANT NOTE: Any operation that generates redo MUST check that there
@@ -1306,6 +1307,25 @@ row_purge_step(
node->start();
+#ifdef UNIV_DEBUG
+ srv_slot_t *slot = thr->thread_slot;
+ ut_ad(slot);
+
+ rw_lock_x_lock(&slot->debug_sync_lock);
+ while (UT_LIST_GET_LEN(slot->debug_sync)) {
+ srv_slot_t::debug_sync_t *sync =
+ UT_LIST_GET_FIRST(slot->debug_sync);
+ bool result = debug_sync_set_action(current_thd,
+ sync->str,
+ strlen(sync->str));
+ ut_a(!result);
+
+ UT_LIST_REMOVE(slot->debug_sync, sync);
+ ut_free(sync);
+ }
+ rw_lock_x_unlock(&slot->debug_sync_lock);
+#endif
+
if (!(node->undo_recs == NULL || ib_vector_is_empty(node->undo_recs))) {
trx_purge_rec_t*purge_rec;
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index cde4e9e7b89..a5ef82405d4 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -466,6 +466,7 @@ row_vers_build_clust_v_col(
vcol_info->set_used();
maria_table = vcol_info->table();
}
+ DEBUG_SYNC(current_thd, "ib_clust_v_col_before_row_allocated");
ib_vcol_row vc(NULL);
byte *record = vc.record(thd, index, &maria_table);
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 3da92d48feb..9d19a14cb66 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -2518,6 +2518,13 @@ DECLARE_THREAD(srv_worker_thread)(
slot = srv_reserve_slot(SRV_WORKER);
+#ifdef UNIV_DEBUG
+ UT_LIST_INIT(slot->debug_sync,
+ &srv_slot_t::debug_sync_t::debug_sync_list);
+ rw_lock_create(PFS_NOT_INSTRUMENTED, &slot->debug_sync_lock,
+ SYNC_NO_ORDER_CHECK);
+#endif
+
ut_a(srv_n_purge_threads > 1);
ut_a(ulong(my_atomic_loadlint(&srv_sys.n_threads_active[SRV_WORKER]))
< srv_n_purge_threads);
@@ -2539,6 +2546,8 @@ DECLARE_THREAD(srv_worker_thread)(
}
} while (purge_sys.enabled());
+ ut_d(rw_lock_free(&slot->debug_sync_lock));
+
srv_free_slot(slot);
ut_ad(!purge_sys.enabled());
@@ -2739,6 +2748,12 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
slot = srv_reserve_slot(SRV_PURGE);
+#ifdef UNIV_DEBUG
+ UT_LIST_INIT(slot->debug_sync,
+ &srv_slot_t::debug_sync_t::debug_sync_list);
+ rw_lock_create(PFS_NOT_INSTRUMENTED, &slot->debug_sync_lock,
+ SYNC_NO_ORDER_CHECK);
+#endif
ulint rseg_history_len = trx_sys.history_size();
do {
@@ -2767,6 +2782,8 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
shutdown state. */
ut_a(srv_get_task_queue_length() == 0);
+ ut_d(rw_lock_free(&slot->debug_sync_lock));
+
srv_free_slot(slot);
/* Note that we are shutting down. */
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index d519265dc8a..88ff251548c 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -805,7 +805,8 @@ void trx_rollback_recovered(bool all)
srv_fast_shutdown)
goto discard;
- if (all || trx_get_dict_operation(trx) != TRX_DICT_OP_NONE)
+ if (all || trx_get_dict_operation(trx) != TRX_DICT_OP_NONE
+ || trx->has_stats_table_lock())
{
trx_rollback_active(trx);
if (trx->error_state != DB_SUCCESS)
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 90ed4141633..2620005269c 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -2404,3 +2404,16 @@ trx_set_rw_mode(
trx->read_view.set_creator_trx_id(trx->id);
}
}
+
+bool trx_t::has_stats_table_lock() const
+{
+ for (lock_list::const_iterator it= lock.table_locks.begin(),
+ end= lock.table_locks.end(); it != end; ++it)
+ {
+ const lock_t *lock= *it;
+ if (lock && lock->un_member.tab_lock.table->is_stats_table())
+ return true;
+ }
+
+ return false;
+}