From 8dddff226c8bbbc3426ce74fb2ae98992e9221ec Mon Sep 17 00:00:00 2001 From: YoungYang0820 Date: Wed, 13 Oct 2021 17:12:29 +0800 Subject: [PATCH] fix unexpected error log in ObMacroBlockWriter when creating unique index --- src/storage/blocksstable/ob_macro_block.cpp | 2 ++ src/storage/blocksstable/ob_macro_block.h | 3 ++- src/storage/blocksstable/ob_macro_block_writer.cpp | 7 ++++++- src/storage/ob_build_index_task.cpp | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/storage/blocksstable/ob_macro_block.cpp b/src/storage/blocksstable/ob_macro_block.cpp index d65f512ac3..5e948bc7d9 100644 --- a/src/storage/blocksstable/ob_macro_block.cpp +++ b/src/storage/blocksstable/ob_macro_block.cpp @@ -264,6 +264,7 @@ void ObDataStoreDesc::reset() progressive_merge_round_ = 0; major_working_cluster_version_ = 0; iter_complement_ = false; + is_unique_index_ = false; } int ObDataStoreDesc::assign(const ObDataStoreDesc& desc) @@ -303,6 +304,7 @@ int ObDataStoreDesc::assign(const ObDataStoreDesc& desc) pg_key_ = desc.pg_key_; need_check_order_ = desc.need_check_order_; major_working_cluster_version_ = desc.major_working_cluster_version_; + is_unique_index_ = desc.is_unique_index_; if (OB_FAIL(file_handle_.assign(desc.file_handle_))) { STORAGE_LOG(WARN, "failed to assign file handle", K(ret), K(desc.file_handle_)); } diff --git a/src/storage/blocksstable/ob_macro_block.h b/src/storage/blocksstable/ob_macro_block.h index 447ab0d6b0..602a381cbb 100644 --- a/src/storage/blocksstable/ob_macro_block.h +++ b/src/storage/blocksstable/ob_macro_block.h @@ -74,6 +74,7 @@ struct ObDataStoreDesc { // which still use freezeinfo without cluster version int64_t major_working_cluster_version_; bool iter_complement_; + bool is_unique_index_; common::ObArenaAllocator allocator_; ObDataStoreDesc() @@ -103,7 +104,7 @@ struct ObDataStoreDesc { K_(store_micro_block_column_checksum), K_(snapshot_version), K_(need_calc_physical_checksum), K_(need_index_tree), K_(need_prebuild_bloomfilter), K_(bloomfilter_rowkey_prefix), KP_(rowkey_helper), "column_types", common::ObArrayWrap(column_types_, row_column_count_), K_(pg_key), K_(file_handle), - K_(need_check_order), K_(need_index_tree), K_(major_working_cluster_version), K_(iter_complement)); + K_(need_check_order), K_(need_index_tree), K_(major_working_cluster_version), K_(iter_complement), K_(is_unique_index)); private: int cal_row_store_type(const share::schema::ObTableSchema& table_schema, const storage::ObMergeType merge_type); diff --git a/src/storage/blocksstable/ob_macro_block_writer.cpp b/src/storage/blocksstable/ob_macro_block_writer.cpp index 323bb33d97..cd4a90c003 100644 --- a/src/storage/blocksstable/ob_macro_block_writer.cpp +++ b/src/storage/blocksstable/ob_macro_block_writer.cpp @@ -851,7 +851,12 @@ int ObMacroBlockWriter::check_order(const ObStoreRow& row) } else { // baseline data ret = OB_ERR_PRIMARY_KEY_DUPLICATE; - STORAGE_LOG(ERROR, "input rowkey is equal with last rowkey", K(cur_key), K(last_key), K(ret)); + if (data_store_desc_->is_unique_index_) { + STORAGE_LOG( + WARN, "input rowkey is equal with last rowkey in unique index", K(cur_key), K(last_key), K(ret)); + } else { + STORAGE_LOG(ERROR, "input rowkey is equal with last rowkey", K(cur_key), K(last_key), K(ret)); + } } } else { // normal case diff --git a/src/storage/ob_build_index_task.cpp b/src/storage/ob_build_index_task.cpp index c61d5df967..bda16e300f 100644 --- a/src/storage/ob_build_index_task.cpp +++ b/src/storage/ob_build_index_task.cpp @@ -825,6 +825,7 @@ int ObIndexMergeTask::add_build_index_sstable(const ObBuildIndexParam& param, pg->get_partition_key(), pg->get_storage_file_handle()))) { STORAGE_LOG(WARN, "Fail to init data store desc, ", K(ret)); + } else if (FALSE_IT(data_desc_.is_unique_index_ = param.index_schema_->is_unique_index())) { } else if (OB_FAIL(writer_.open(data_desc_, macro_start_seq))) { STORAGE_LOG(WARN, "Fail to open macro block writer, ", K(ret)); } else {