From 8cfd7c44d90a6a1f8437fc450e5ca618295eff8c Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 6 Feb 2024 21:53:40 +0000 Subject: [PATCH] [CP] use is_schema_changed on medium info --- .../compaction/ob_basic_tablet_merge_ctx.cpp | 4 +++- .../compaction/ob_medium_compaction_func.cpp | 10 +++++----- .../compaction/ob_medium_compaction_func.h | 5 ++--- .../compaction/ob_medium_compaction_info.cpp | 20 ++++++++++--------- .../compaction/ob_medium_compaction_info.h | 3 ++- src/storage/ob_storage_schema.cpp | 2 -- src/storage/ob_storage_schema.h | 5 +---- src/storage/tablet/ob_tablet_meta.cpp | 1 - 8 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp b/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp index 94b6f6e5e5..862bdff5d5 100644 --- a/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp +++ b/src/storage/compaction/ob_basic_tablet_merge_ctx.cpp @@ -1004,7 +1004,9 @@ int ObBasicTabletMergeCtx::get_medium_compaction_info() static_param_.data_version_ = medium_info.data_version_; static_param_.is_rebuild_column_store_ = (medium_info.medium_merge_reason_ == ObAdaptiveMergePolicy::REBUILD_COLUMN_GROUP); static_param_.is_tenant_major_merge_ = medium_info.is_major_compaction(); - static_param_.is_schema_changed_ = medium_info.is_schema_changed_; + if (medium_info.medium_compat_version_ >= ObMediumCompactionInfo::MEDIUM_COMPAT_VERSION_V4) { + static_param_.is_schema_changed_ = medium_info.is_schema_changed_; + } static_param_.merge_reason_ = (ObAdaptiveMergePolicy::AdaptiveMergeReason)medium_info.medium_merge_reason_; FLOG_INFO("get storage schema to merge", "param", get_dag_param(), KPC_(static_param_.schema), K(medium_info)); } diff --git a/src/storage/compaction/ob_medium_compaction_func.cpp b/src/storage/compaction/ob_medium_compaction_func.cpp index 63a965ff50..4a014996fc 100644 --- a/src/storage/compaction/ob_medium_compaction_func.cpp +++ b/src/storage/compaction/ob_medium_compaction_func.cpp @@ -115,7 +115,7 @@ int ObMediumCompactionScheduleFunc::find_valid_freeze_info( ret = OB_ERR_UNEXPECTED; LOG_WARN("failed to get schema service from MTL", K(ret)); } else if (OB_FAIL(tablet.fetch_table_store(table_store_wrapper))) { - LOG_WARN("load medium info list fail", K(ret), K(tablet)); + LOG_WARN("failed to fetch table store", K(ret), K(tablet)); } else { last_major = static_cast(table_store_wrapper.get_member()->get_major_sstables().get_boundary_table(true/*last*/)); if (OB_ISNULL(last_major)) { @@ -501,7 +501,7 @@ int ObMediumCompactionScheduleFunc::get_max_reserved_snapshot(int64_t &max_reser // not sync reserved snapshot yet, should not schedule now } else if (OB_FAIL(MTL(ObTenantFreezeInfoMgr*)->get_min_reserved_snapshot( tablet->get_tablet_meta().tablet_id_, last_major_snapshot_version, snapshot_info))) { - LOG_WARN("failed to get multi version from freeze info mgr", K(ret), "tablet_id", tablet->get_tablet_meta().tablet_id_); + LOG_WARN("failed to get reserved snapshot from freeze info mgr", K(ret), "tablet_id", tablet->get_tablet_meta().tablet_id_); } else { max_reserved_snapshot = MAX(ls_.get_min_reserved_snapshot(), snapshot_info.snapshot_); } @@ -564,14 +564,14 @@ int ObMediumCompactionScheduleFunc::decide_medium_snapshot( LOG_WARN("failed to add dependent tablet", K(ret), KPC(this)); } else { const ObTabletID &tablet_id = tablet->get_tablet_meta().tablet_id_; - LOG_TRACE("decide_medium_snapshot", K(ret), KPC(this), K(tablet_id)); + LOG_TRACE("decide_medium_snapshot", K(ret), KPC(this), K(compat_version), K(tablet_id), K(max_sync_medium_scn), K(merge_reason)); int64_t max_reserved_snapshot = 0; int64_t schema_version = 0; ObGetMergeTablesResult result; ObMediumCompactionInfo medium_info; - if (OB_FAIL(medium_info.init_data_version())) { - LOG_WARN("fail to set data version", K(ret)); + if (OB_FAIL(medium_info.init_data_version(compat_version))) { + LOG_WARN("fail to set data version", K(ret), K(tablet_id), K(compat_version)); } else if (is_user_request(merge_reason)) { if (OB_FAIL(choose_medium_scn_for_user_request(medium_info, result, schema_version))) { LOG_WARN("failed to choose medium scn for user request", K(ret), KPC(this)); diff --git a/src/storage/compaction/ob_medium_compaction_func.h b/src/storage/compaction/ob_medium_compaction_func.h index 113a3a7b7f..e59d7e5958 100644 --- a/src/storage/compaction/ob_medium_compaction_func.h +++ b/src/storage/compaction/ob_medium_compaction_func.h @@ -79,11 +79,10 @@ public: const int64_t major_snapshot, const bool force_schedule); - int decide_medium_snapshot( - const ObAdaptiveMergePolicy::AdaptiveMergeReason merge_reason); - int64_t to_string(char* buf, const int64_t buf_len) const; protected: + int decide_medium_snapshot( + const ObAdaptiveMergePolicy::AdaptiveMergeReason merge_reason); static int get_status_from_inner_table( const ObLSID &ls_id, const ObTabletID &tablet_id, diff --git a/src/storage/compaction/ob_medium_compaction_info.cpp b/src/storage/compaction/ob_medium_compaction_info.cpp index ad543accab..44226ba8ad 100644 --- a/src/storage/compaction/ob_medium_compaction_info.cpp +++ b/src/storage/compaction/ob_medium_compaction_info.cpp @@ -351,16 +351,16 @@ const char *ObMediumCompactionInfo::ObCompactionTypeStr[] = { const char *ObMediumCompactionInfo::get_compaction_type_str(enum ObCompactionType type) { const char *str = ""; - if (type >= COMPACTION_TYPE_MAX || type < MEDIUM_COMPACTION) { - str = "invalid_type"; - } else { + if (is_valid_compaction_type(type)) { str = ObCompactionTypeStr[type]; + } else { + str = "invalid_type"; } return str; } ObMediumCompactionInfo::ObMediumCompactionInfo() - : medium_compat_version_(MEDIUM_COMPAT_VERSION_V3), + : medium_compat_version_(MEDIUM_COMPAT_VERSION_V4), compaction_type_(COMPACTION_TYPE_MAX), contain_parallel_range_(false), medium_merge_reason_(ObAdaptiveMergePolicy::NONE), @@ -410,12 +410,12 @@ int ObMediumCompactionInfo::init( return ret; } -int ObMediumCompactionInfo::init_data_version() +int ObMediumCompactionInfo::init_data_version(const uint64_t compat_version) { int ret = OB_SUCCESS; - uint64_t compat_version = 0; - if (OB_FAIL(GET_MIN_DATA_VERSION(MTL_ID(), compat_version))) { - LOG_WARN("fail to get data version", K(ret)); + if (OB_UNLIKELY(compat_version <= 0)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid input compat version", K(ret), K(compat_version)); } else if (OB_UNLIKELY(compat_version < DATA_VERSION_4_1_0_0)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("invalid data version to schedule medium compaction", K(ret), K(compat_version)); @@ -425,8 +425,10 @@ int ObMediumCompactionInfo::init_data_version() medium_compat_version_ = ObMediumCompactionInfo::MEDIUM_COMPAT_VERSION; } else if (compat_version < DATA_VERSION_4_2_1_0) { medium_compat_version_ = ObMediumCompactionInfo::MEDIUM_COMPAT_VERSION_V2; - } else { + } else if (compat_version < DATA_VERSION_4_2_1_2) { medium_compat_version_ = ObMediumCompactionInfo::MEDIUM_COMPAT_VERSION_V3; + } else { + medium_compat_version_ = ObMediumCompactionInfo::MEDIUM_COMPAT_VERSION_V4; } } return ret; diff --git a/src/storage/compaction/ob_medium_compaction_info.h b/src/storage/compaction/ob_medium_compaction_info.h index 7d869b3726..e5ea32bcdb 100644 --- a/src/storage/compaction/ob_medium_compaction_info.h +++ b/src/storage/compaction/ob_medium_compaction_info.h @@ -180,7 +180,7 @@ public: int assign(ObIAllocator &allocator, const ObMediumCompactionInfo &medium_info); int init(ObIAllocator &allocator, const ObMediumCompactionInfo &medium_info); - int init_data_version(); + int init_data_version(const uint64_t compat_version); void set_basic_info( const ObCompactionType type, const ObAdaptiveMergePolicy::AdaptiveMergeReason merge_reason, @@ -222,6 +222,7 @@ public: static const int64_t MEDIUM_COMPAT_VERSION = 1; static const int64_t MEDIUM_COMPAT_VERSION_V2 = 2; // for add last_medium_snapshot_ static const int64_t MEDIUM_COMPAT_VERSION_V3 = 3; // for stanby tenant, not throw medium info + static const int64_t MEDIUM_COMPAT_VERSION_V4 = 4; // after this version, use is_schema_changed on medium info private: static const int32_t SCS_ONE_BIT = 1; static const int32_t SCS_RESERVED_BITS = 32; diff --git a/src/storage/ob_storage_schema.cpp b/src/storage/ob_storage_schema.cpp index 6ed5e3c28c..2f042811a6 100644 --- a/src/storage/ob_storage_schema.cpp +++ b/src/storage/ob_storage_schema.cpp @@ -367,7 +367,6 @@ ObStorageSchema::ObStorageSchema() table_type_(ObTableType::MAX_TABLE_TYPE), table_mode_(), index_type_(ObIndexType::INDEX_TYPE_IS_NOT), - index_status_(ObIndexStatus::INDEX_STATUS_UNAVAILABLE), row_store_type_(ObStoreFormat::get_default_row_store_type()), schema_version_(OB_INVALID_VERSION), column_cnt_(0), @@ -1533,7 +1532,6 @@ void ObStorageSchema::copy_from(const share::schema::ObMergeSchema &input_schema table_type_ = input_schema.get_table_type(); table_mode_ = input_schema.get_table_mode_struct(); index_type_ = input_schema.get_index_type(); - index_status_ = input_schema.get_index_status(); row_store_type_ = input_schema.get_row_store_type(); schema_version_ = input_schema.get_schema_version(); column_cnt_ = input_schema.get_column_count(); diff --git a/src/storage/ob_storage_schema.h b/src/storage/ob_storage_schema.h index b6124dcd83..944cf2c6d2 100644 --- a/src/storage/ob_storage_schema.h +++ b/src/storage/ob_storage_schema.h @@ -233,7 +233,6 @@ public: virtual inline share::schema::ObTableMode get_table_mode_struct() const override { return table_mode_; } virtual inline share::schema::ObTableType get_table_type() const override { return table_type_; } virtual inline share::schema::ObIndexType get_index_type() const override { return index_type_; } - virtual inline share::schema::ObIndexStatus get_index_status() const override { return index_status_; } const common::ObIArray &get_store_column_schemas() const { return column_array_; } const common::ObIArray &get_column_groups() const { return column_group_array_; } virtual inline common::ObRowStoreType get_row_store_type() const override { return row_store_type_; } @@ -262,7 +261,7 @@ public: VIRTUAL_TO_STRING_KV(KP(this), K_(storage_schema_version), K_(version), K_(is_use_bloomfilter), K_(column_info_simplified), K_(compat_mode), K_(table_type), K_(index_type), - K_(index_status), K_(row_store_type), K_(schema_version), + K_(row_store_type), K_(schema_version), K_(column_cnt), K_(store_column_cnt), K_(tablet_size), K_(pctfree), K_(block_size), K_(progressive_merge_round), K_(master_key_id), K_(compressor_type), K_(encryption), K_(encrypt_key), "rowkey_cnt", rowkey_array_.count(), K_(rowkey_array), "column_cnt", column_array_.count(), K_(column_array), @@ -333,8 +332,6 @@ public: share::schema::ObTableType table_type_; share::schema::ObTableMode table_mode_; share::schema::ObIndexType index_type_; - share::schema::ObIndexStatus index_status_; - ObRowStoreType row_store_type_; int64_t schema_version_; int64_t column_cnt_; // include virtual generated column diff --git a/src/storage/tablet/ob_tablet_meta.cpp b/src/storage/tablet/ob_tablet_meta.cpp index 3432738441..bf35909090 100644 --- a/src/storage/tablet/ob_tablet_meta.cpp +++ b/src/storage/tablet/ob_tablet_meta.cpp @@ -1410,7 +1410,6 @@ int ObMigrationTabletParam::construct_placeholder_storage_schema_and_medium( storage_schema.table_type_ = ObTableType::USER_TABLE; //storage_schema.table_mode_ storage_schema.index_type_ = ObIndexType::INDEX_TYPE_PRIMARY; - storage_schema.index_status_ = ObIndexStatus::INDEX_STATUS_AVAILABLE; storage_schema.row_store_type_ = ObRowStoreType::FLAT_ROW_STORE; storage_schema.schema_version_ = ObStorageSchema::STORAGE_SCHEMA_VERSION_V3; storage_schema.column_cnt_ = 1;