From 3ff5fb988b809ba82b9b2c243b4f08e8175e0eb3 Mon Sep 17 00:00:00 2001 From: "wanhong.wwh" Date: Tue, 21 Jun 2022 10:53:24 +0800 Subject: [PATCH] [CP] Fix global index issues: after drop/truncate partition, global index can not rereplicate --- src/rootserver/ob_balance_info.h | 4 +--- src/share/schema/ob_schema_struct.cpp | 6 ++++++ src/share/schema/ob_schema_struct.h | 6 ++++++ src/share/schema/ob_table_schema.h | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/rootserver/ob_balance_info.h b/src/rootserver/ob_balance_info.h index ae0d6e22e6..db110b85c8 100644 --- a/src/rootserver/ob_balance_info.h +++ b/src/rootserver/ob_balance_info.h @@ -1229,9 +1229,7 @@ int TenantBalanceStat::fill_partition_entity(const uint64_t schema_id, const SCH } else if (OB_FAIL(build_readonly_at_all_info(schema_id, schema))) { RS_LOG(WARN, "fail to build readonly at all info", K(ret), K(schema_id)); } else { - bool can_do_rereplicate = - !schema.is_global_index_table() || (schema.is_global_index_table() && schema.can_read_index()) || - (schema.is_global_index_table() && schema.is_mock_global_index_invalid() && !schema.can_read_index()); + bool can_do_rereplicate = !schema.is_global_index_table() || schema.can_rereplicate_global_index_table(); share::ObPartitionInfo info; int64_t partition_idx = OB_INVALID_INDEX; bool check_dropped_partition = true; diff --git a/src/share/schema/ob_schema_struct.cpp b/src/share/schema/ob_schema_struct.cpp index 50d095cc8b..6c01f01a7a 100644 --- a/src/share/schema/ob_schema_struct.cpp +++ b/src/share/schema/ob_schema_struct.cpp @@ -7743,6 +7743,12 @@ const char* ob_view_check_option_str(const ViewCheckOption option) return ret; } +bool can_rereplicate_index_status(const ObIndexStatus &idst) +{ + // unusable index can also rereplicate + return INDEX_STATUS_AVAILABLE == idst || INDEX_STATUS_UNUSABLE == idst; +} + const char* ob_index_status_str(ObIndexStatus status) { const char* ret = "invalid"; diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index f477d8202c..329b057d15 100644 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -247,6 +247,8 @@ enum ObIndexStatus { INDEX_STATUS_MAX = 8, }; +bool can_rereplicate_index_status(const ObIndexStatus &idst); + enum ObPartitionStatus { PARTITION_STATUS_INVALID = -1, PARTITION_STATUS_ACTIVE = 0, @@ -3267,6 +3269,10 @@ public: { return true; } + inline bool can_rereplicate_global_index_table() const + { + return true; + } DECLARE_VIRTUAL_TO_STRING; diff --git a/src/share/schema/ob_table_schema.h b/src/share/schema/ob_table_schema.h index a4f8e5ddf7..ed59096385 100644 --- a/src/share/schema/ob_table_schema.h +++ b/src/share/schema/ob_table_schema.h @@ -639,6 +639,13 @@ public: { return INDEX_STATUS_AVAILABLE == index_status && !is_dropped_schema; } + inline bool can_rereplicate_global_index_table() const + { + // 1. index which can rereplicate + // 2. is mocked invalid for standby cluster + return is_global_index_table() && !is_dropped_schema() && + (can_rereplicate_index_status(index_status_) || is_mock_global_index_invalid()); + } inline bool is_final_invalid_index() const; inline void set_index_status(const ObIndexStatus index_status) { -- GitLab