summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-03-07 13:00:59 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-03-07 13:00:59 +0530
commit2458badf9be6f47574e478177031395247c86f8f (patch)
treee221ea1085ee4a5b1637c684fdb4e54e389b58f2
parent062ba0bd4a2da1fc720c7da8feb3f179a9be1583 (diff)
downloadmariadb-git-2458badf9be6f47574e478177031395247c86f8f.tar.gz
MDEV-30798 deadlock between CHECK TABLE and bulk insert
- Deadlock happens when bulk insert acquires the space latch before acquiring the index root page and check table does the opposite. Workaround is to avoid validating the index for check table when bulk insert is in progress for the table.
-rw-r--r--storage/innobase/handler/ha_innodb.cc31
1 files changed, 21 insertions, 10 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 07454d24900..f8807e5fdc7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -15184,16 +15184,26 @@ ha_innobase::check(
}
if ((check_opt->flags & T_QUICK) || index->is_corrupted()) {
- } else if (btr_validate_index(index, m_prebuilt->trx)
- != DB_SUCCESS) {
- is_ok = false;
- push_warning_printf(thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_NOT_KEYFILE,
- "InnoDB: The B-tree of"
- " index %s is corrupted.",
- index->name());
- continue;
+ } else if (trx_id_t bulk_trx_id =
+ m_prebuilt->table->bulk_trx_id) {
+ if (!m_prebuilt->trx->read_view.changes_visible(
+ bulk_trx_id)) {
+ is_ok = true;
+ goto func_exit;
+ }
+
+ if (btr_validate_index(index, m_prebuilt->trx)
+ != DB_SUCCESS) {
+ is_ok = false;
+ push_warning_printf(
+ thd,
+ Sql_condition::WARN_LEVEL_WARN,
+ ER_NOT_KEYFILE,
+ "InnoDB: The B-tree of"
+ " index %s is corrupted.",
+ index->name());
+ continue;
+ }
}
/* Instead of invoking change_active_index(), set up
@@ -15316,6 +15326,7 @@ ha_innobase::check(
}
# endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
#endif /* BTR_CUR_HASH_ADAPT */
+func_exit:
m_prebuilt->trx->op_info = "";
DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);