From 9b1ec8ad7768a210a530b38a8a13ba532b9a3ebd Mon Sep 17 00:00:00 2001 From: Charles0429 Date: Wed, 15 Dec 2021 10:24:53 +0800 Subject: [PATCH] skip building delay deleted index --- src/rootserver/ob_global_index_builder.cpp | 2 ++ src/rootserver/ob_index_builder.cpp | 4 ++-- src/storage/ob_build_index_scheduler.cpp | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rootserver/ob_global_index_builder.cpp b/src/rootserver/ob_global_index_builder.cpp index a28b0360ba..211690bca5 100644 --- a/src/rootserver/ob_global_index_builder.cpp +++ b/src/rootserver/ob_global_index_builder.cpp @@ -565,6 +565,8 @@ int ObGlobalIndexBuilder::check_and_get_index_schema(share::schema::ObSchemaGett } else if (OB_UNLIKELY(NULL == index_schema)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("index schema ptr is null", K(ret), K(index_table_id)); + } else if (index_schema->is_dropped_schema()) { + // table delay delete, do not build index } else { } // no more to do return ret; diff --git a/src/rootserver/ob_index_builder.cpp b/src/rootserver/ob_index_builder.cpp index 6cdeb4ca8d..7d1a63a1d2 100644 --- a/src/rootserver/ob_index_builder.cpp +++ b/src/rootserver/ob_index_builder.cpp @@ -618,7 +618,7 @@ int ObRSBuildIndexTask::wait_trans_end(bool& is_end) LOG_WARN("fail to get schema guard", K(ret), K(fetch_tenant_id), K_(index_id)); } else if (OB_FAIL(schema_guard.get_table_schema(index_id_, index_schema))) { LOG_WARN("fail to get table schema", K(ret), K(index_id_)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || index_schema->is_dropped_schema()) { // index table has been dropped ret = OB_SUCCESS; is_end = true; @@ -732,7 +732,7 @@ int ObRSBuildIndexTask::wait_build_index_end(bool& is_end) LOG_WARN("fail to get schema guard", K(ret), K(fetch_tenant_id), K_(index_id)); } else if (OB_FAIL(schema_guard.get_table_schema(index_id_, index_schema))) { LOG_WARN("fail to get table schema", K(ret), K(index_id_)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || index_schema->is_dropped_schema()) { ret = OB_SUCCESS; is_end = true; } else if (OB_FAIL(schema_guard.get_table_schema(index_schema->get_data_table_id(), table_schema))) { diff --git a/src/storage/ob_build_index_scheduler.cpp b/src/storage/ob_build_index_scheduler.cpp index 181cf9fedb..0920011ef4 100644 --- a/src/storage/ob_build_index_scheduler.cpp +++ b/src/storage/ob_build_index_scheduler.cpp @@ -467,7 +467,7 @@ int ObTenantDDLCheckSchemaTask::process_schedule_build_index_task() // do nothing } else if (OB_FAIL(schema_guard.get_table_schema(table_ids.at(i), index_schema))) { STORAGE_LOG(WARN, "fail to get table schema", K(ret)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || index_schema->is_dropped_schema()) { ret = OB_SUCCESS; STORAGE_LOG(INFO, "table has been deleted, do not need to create index", K(ret), "table_id", table_ids.at(i)); } else if (OB_FAIL(find_build_index_partitions(index_schema, schema_guard, partition_keys))) { @@ -998,7 +998,7 @@ int ObBuildIndexScheduleTask::send_copy_replica_rpc() STORAGE_LOG(WARN, "fail to get schema guard", K(ret), K(schema_version_)); } else if (OB_FAIL(schema_guard.get_table_schema(index_id_, index_schema))) { STORAGE_LOG(WARN, "fail to get table schema", K(ret), K(pkey_), K(index_id_)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || index_schema->is_dropped_schema()) { ret = OB_SUCCESS; } else if (OB_FAIL(schema_guard.get_table_schema(index_schema->get_data_table_id(), data_table_schema))) { STORAGE_LOG(WARN, "fail to get table schema", K(ret)); @@ -1414,7 +1414,7 @@ int ObBuildIndexScheduleTask::process() STORAGE_LOG(WARN, "fail to get schema guard", K(ret), K(pkey_), K(index_id_)); } else if (OB_FAIL(schema_guard.get_table_schema(index_id_, index_schema))) { STORAGE_LOG(WARN, "fail to get table schema", K(ret), K(pkey_), K(index_id_)); - } else if (OB_ISNULL(index_schema)) { + } else if (OB_ISNULL(index_schema) || index_schema->is_dropped_schema()) { if (UNIQUE_INDEX_CHECKING != state_) { STORAGE_LOG(INFO, "index schema has been deleted, skip build it", K(pkey_), K(index_id_)); is_end = true; -- GitLab