From 94816acd47cd5d13bd2c9039e564821d3e35f6af Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 15 Jul 2021 11:39:13 +0800 Subject: [PATCH] patch code from 3_1_x_release --- .../blocksstable/ob_macro_block_writer.cpp | 1 + .../blocksstable/ob_macro_block_writer.h | 2 +- src/storage/compaction/ob_partition_merge.cpp | 7 +- .../compaction/ob_partition_merge_builder.cpp | 46 ++- .../compaction/ob_partition_merge_builder.h | 7 + .../compaction/ob_partition_merge_util.cpp | 5 +- src/storage/memtable/ob_memtable_iterator.cpp | 4 +- src/storage/ob_row_fuse.cpp | 1 + src/storage/ob_sstable_dump_error_info.cpp | 169 ++++----- src/storage/ob_sstable_dump_error_info.h | 36 +- unittest/storage/test_new_minor_fuser.cpp | 174 ++++----- .../test_partition_merge_multi_version.cpp | 332 +++++++++++++----- 12 files changed, 513 insertions(+), 271 deletions(-) diff --git a/src/storage/blocksstable/ob_macro_block_writer.cpp b/src/storage/blocksstable/ob_macro_block_writer.cpp index a4384517f9..323bb33d97 100644 --- a/src/storage/blocksstable/ob_macro_block_writer.cpp +++ b/src/storage/blocksstable/ob_macro_block_writer.cpp @@ -806,6 +806,7 @@ int ObMacroBlockWriter::check_order(const ObStoreRow& row) } } else if (!row.row_type_flag_.is_uncommitted_row()) { // update max commit version micro_writer_->update_max_merged_trans_version(-cur_row_version); + row.row_val_.cells_[sql_sequence_col_idx].set_int(0); // make sql sequence = 0 } else { // not committed micro_writer_->set_contain_uncommitted_row(); LOG_TRACE("meet uncommited trans row", K(row)); diff --git a/src/storage/blocksstable/ob_macro_block_writer.h b/src/storage/blocksstable/ob_macro_block_writer.h index 5559fe1d42..e4a7f83cca 100644 --- a/src/storage/blocksstable/ob_macro_block_writer.h +++ b/src/storage/blocksstable/ob_macro_block_writer.h @@ -70,6 +70,7 @@ public: { return task_index_writer_->get_macro_block_write_ctx(); } + int dump_micro_block_writer_buffer(); TO_STRING_KV(K_(block_write_ctx)); struct IndexMicroBlockBuilder { @@ -159,7 +160,6 @@ private: int prepare_micro_block_reader(const char* buf, const int64_t size, ObIMicroBlockReader*& micro_reader); int print_micro_block_row(ObIMicroBlockReader* micro_reader); - int dump_micro_block_writer_buffer(); private: static const int64_t DEFAULT_MACRO_BLOCK_COUNT = 128; diff --git a/src/storage/compaction/ob_partition_merge.cpp b/src/storage/compaction/ob_partition_merge.cpp index fa1d8b3675..a2ba5e51cc 100644 --- a/src/storage/compaction/ob_partition_merge.cpp +++ b/src/storage/compaction/ob_partition_merge.cpp @@ -1363,7 +1363,7 @@ int ObMinorPartitionMergeFuser::set_multi_version_row_flag( const MERGE_ITER_ARRAY& macro_row_iters, ObStoreRow& store_row) { int ret = OB_SUCCESS; - store_row.row_type_flag_.set_compacted_multi_version_row(false); + store_row.row_type_flag_.set_compacted_multi_version_row(true); store_row.row_type_flag_.set_first_multi_version_row(true); if (need_check_curr_row_last_) { store_row.row_type_flag_.set_last_multi_version_row(true); @@ -1372,9 +1372,8 @@ int ObMinorPartitionMergeFuser::set_multi_version_row_flag( } for (int64_t i = 0; i < macro_row_iters.count(); ++i) { - if (macro_row_iters.at(i)->get_curr_row()->row_type_flag_.is_compacted_multi_version_row() || - !macro_row_iters.at(i)->get_table()->is_multi_version_table()) { - store_row.row_type_flag_.set_compacted_multi_version_row(true); + if (!macro_row_iters.at(i)->get_curr_row()->row_type_flag_.is_compacted_multi_version_row()) { + store_row.row_type_flag_.set_compacted_multi_version_row(false); break; } } diff --git a/src/storage/compaction/ob_partition_merge_builder.cpp b/src/storage/compaction/ob_partition_merge_builder.cpp index 5c5a2f30ae..90ba88720a 100644 --- a/src/storage/compaction/ob_partition_merge_builder.cpp +++ b/src/storage/compaction/ob_partition_merge_builder.cpp @@ -45,7 +45,9 @@ ObMacroBlockBuilder::ObMacroBlockBuilder() need_build_bloom_filter_(false), bf_macro_writer_(), cols_id_map_(nullptr), - is_opened_(false) + is_opened_(false), + check_row_flag_status_(CHECK_FIRST_ROW), + last_compact_row_nop_cnt_(-1) {} ObMacroBlockBuilder::~ObMacroBlockBuilder() @@ -352,6 +354,8 @@ int ObMacroBlockBuilder::process(const blocksstable::ObMacroBlockCtx& macro_bloc } else if (OB_FAIL(writer_->append_macro_block(macro_block_ctx))) { STORAGE_LOG(WARN, "macro block writer fail to close.", K(ret)); } else { + check_row_flag_status_ = CHECK_FIRST_ROW; + last_compact_row_nop_cnt_ = -1; STORAGE_LOG(DEBUG, "Success to append macro block, ", K(macro_block_ctx)); } return ret; @@ -423,12 +427,18 @@ int ObMacroBlockBuilder::check_flat_row_columns(const ObStoreRow& row) { int ret = OB_SUCCESS; if (ObActionFlag::OP_ROW_EXIST != row.flag_) { + if (row.row_type_flag_.is_last_multi_version_row()) { // meet last row + check_row_flag_status_ = CHECK_FIRST_ROW; + last_compact_row_nop_cnt_ = -1; + } } else if (row.row_val_.count_ != desc_.row_column_count_) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("Unexpected column count of store row", K(row), K_(desc), K(ret)); } else { const int64_t interval = 4; int64_t i = 0; + int64_t nop_pos_cnt = 0; + bool check_nop_pos_flag = desc_.is_multi_version_minor_sstable(); for (i = 0; i + interval < row.row_val_.count_; i += interval) { const int tmp0 = check_row_column(row, i + 0); const int tmp1 = check_row_column(row, i + 1); @@ -438,14 +448,43 @@ int ObMacroBlockBuilder::check_flat_row_columns(const ObStoreRow& row) ret = OB_ERR_UNEXPECTED; LOG_WARN("failed to check row column", K(ret), K(i), K(interval), K(row)); break; + } else if (check_nop_pos_flag) { + nop_pos_cnt += (row.row_val_.cells_[i].is_nop_value() + + row.row_val_.cells_[i + 1].is_nop_value() + + row.row_val_.cells_[i + 2].is_nop_value() + + row.row_val_.cells_[i + 3].is_nop_value()); } } - for (; OB_SUCC(ret) && i < row.row_val_.count_; ++i) { if (OB_FAIL(check_row_column(row, i))) { LOG_WARN("failed to check row column", K(ret), K(i)); + } else if (check_nop_pos_flag) { + nop_pos_cnt += row.row_val_.cells_[i].is_nop_value(); } } + + if (OB_SUCC(ret) && check_nop_pos_flag) { + if (row.row_type_flag_.is_uncommitted_row()) { + // do nothing + } else if (CHECK_FIRST_ROW == check_row_flag_status_) { // meet first committed row + check_row_flag_status_ = CHECK_LAST_ROW; + } else if (CHECK_LAST_ROW == check_row_flag_status_) { + if (nop_pos_cnt < last_compact_row_nop_cnt_) { + ret = OB_ERR_UNEXPECTED; + LOG_ERROR("nop_cnt of current row is less than last compact row", K(ret), K(nop_pos_cnt), + K(row), K(last_compact_row_nop_cnt_)); + } + } + if (row.row_type_flag_.is_last_multi_version_row()) { // meet last row + check_row_flag_status_ = CHECK_FIRST_ROW; + last_compact_row_nop_cnt_ = -1; + } else if (row.row_type_flag_.is_compacted_multi_version_row() + && ObActionFlag::OP_ROW_DOES_NOT_EXIST != row.flag_ + && ObActionFlag::OP_DEL_ROW != row.flag_) { + last_compact_row_nop_cnt_ = nop_pos_cnt; + } + } + } return ret; @@ -550,6 +589,7 @@ int ObMacroBlockBuilder::process(const ObStoreRow& row, const ObCompactRowType:: STORAGE_LOG(WARN, "The row is invalid, ", K(row), K(ret)); } else if (OB_FAIL(check_row_columns(row))) { STORAGE_LOG(WARN, "The row is invalid, ", K(row), K_(desc), K(ret)); + writer_->dump_micro_block_writer_buffer(); } else if (!is_multi_version_minor_merge(merge_type_)) { if ((ObActionFlag::OP_ROW_EXIST == row.flag_ || row.row_type_flag_.is_uncommitted_row()) && OB_FAIL(writer_->append_row(row))) { @@ -690,6 +730,8 @@ void ObMacroBlockBuilder::reset() need_build_bloom_filter_ = false; bf_macro_writer_.reset(); is_opened_ = false; + check_row_flag_status_ = CHECK_FIRST_ROW; + last_compact_row_nop_cnt_ = -1; } void ObMacroBlockBuilder::set_purged_count(const int64_t count) diff --git a/src/storage/compaction/ob_partition_merge_builder.h b/src/storage/compaction/ob_partition_merge_builder.h index 3dc443dc0e..f1e2559544 100644 --- a/src/storage/compaction/ob_partition_merge_builder.h +++ b/src/storage/compaction/ob_partition_merge_builder.h @@ -96,6 +96,11 @@ protected: OB_INLINE int check_sparse_row_column(const common::ObObj& obj, const int64_t idx); int append_bloom_filter(const storage::ObStoreRow& row); + enum CheckRowFlagStatus + { + CHECK_FIRST_ROW = 0, + CHECK_LAST_ROW = 1, + }; private: storage::ObMergeType merge_type_; blocksstable::ObMacroBlockWriter* writer_; @@ -109,6 +114,8 @@ private: blocksstable::ObBloomFilterDataWriter bf_macro_writer_; share::schema::ColumnMap* cols_id_map_; bool is_opened_; + CheckRowFlagStatus check_row_flag_status_; + int64_t last_compact_row_nop_cnt_; }; class ObMacroBlockEstimator : public ObIStoreRowProcessor { diff --git a/src/storage/compaction/ob_partition_merge_util.cpp b/src/storage/compaction/ob_partition_merge_util.cpp index 3eeade9109..5db7b87dee 100644 --- a/src/storage/compaction/ob_partition_merge_util.cpp +++ b/src/storage/compaction/ob_partition_merge_util.cpp @@ -1213,8 +1213,9 @@ int ObMinorMergeMacroRowIterator::next() // the first output row of each rowkey must be compact row // skip the uncommited row and magic row(last row) check_first_row_compacted_ = false; - if (curr_row_->row_type_flag_.is_compacted_multi_version_row()) { // do nothing for compacted row - // do nothing + if (curr_row_->row_type_flag_.is_compacted_multi_version_row() + && 0 == curr_row_->row_val_.cells_[multi_version_row_info_->trans_version_index_ + 1].get_int()) { + // curr row is compact row && is not a uncommitted->committed row } else if (OB_FAIL(make_first_row_compacted())) { LOG_WARN("Fail to compact first row, ", K(ret)); } else if (OB_FAIL(row_queue_.get_next_row(curr_row_))) { // return first row in row_queue diff --git a/src/storage/memtable/ob_memtable_iterator.cpp b/src/storage/memtable/ob_memtable_iterator.cpp index eed27503a9..4eb2cc9770 100644 --- a/src/storage/memtable/ob_memtable_iterator.cpp +++ b/src/storage/memtable/ob_memtable_iterator.cpp @@ -927,13 +927,15 @@ int ObMemtableMultiVersionScanIterator::init(const storage::ObTableIterParam& pa int ObMemtableMultiVersionScanIterator::init_row_cells(ObIAllocator* allocator) { int ret = OB_SUCCESS; + void *buf = nullptr; if (OB_ISNULL(allocator)) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "allocator is null", K(ret), K(allocator)); - } else if (NULL == (row_.row_val_.cells_ = (ObObj*)allocator->alloc(sizeof(ObObj) * columns_.count()))) { + } else if (NULL == (buf = (ObObj*)allocator->alloc(sizeof(ObObj) * columns_.count()))) { ret = OB_ALLOCATE_MEMORY_FAILED; TRANS_LOG(WARN, "alloc cells fail", K(ret), "size", sizeof(ObObj) * columns_.count()); } else { + row_.row_val_.cells_ = new (buf) ObObj[columns_.count()]; row_.row_val_.count_ = columns_.count(); } return ret; diff --git a/src/storage/ob_row_fuse.cpp b/src/storage/ob_row_fuse.cpp index e0858a9570..422e224dea 100644 --- a/src/storage/ob_row_fuse.cpp +++ b/src/storage/ob_row_fuse.cpp @@ -216,6 +216,7 @@ OB_INLINE static int simple_fuse_row( if (common::ObActionFlag::OP_DEL_ROW == former.flag_) { final_result = true; if (first_val) { // copy rowkey + result.row_val_.count_ = former.row_val_.count_; for (int i = 0; OB_SUCC(ret) && i < former.row_val_.count_; ++i) { if (OB_FAIL(obj_copy(former.row_val_.cells_[i], result.row_val_.cells_[i]))) { STORAGE_LOG(WARN, "failed to copy obj", K(ret), K(i), K(former.row_val_.cells_[i])); diff --git a/src/storage/ob_sstable_dump_error_info.cpp b/src/storage/ob_sstable_dump_error_info.cpp index 645bf74599..0429e63788 100644 --- a/src/storage/ob_sstable_dump_error_info.cpp +++ b/src/storage/ob_sstable_dump_error_info.cpp @@ -30,24 +30,26 @@ int ObSSTableDumpErrorInfo::get_sstable_scan_iter( range.get_range().set_whole_range(); if (OB_FAIL(range.to_collation_free_range_on_demand_and_cutoff_range(allocator_))) { STORAGE_LOG(WARN, "failed to transform range to collation free and range cutoff", K(range), K(ret)); - } else if (OB_FAIL(prepare_sstable_query_param(sstable, schema))) { + } else if (OB_FAIL(prepare_sstable_query_param(sstable, schema, query_param_for_table1_))) { STORAGE_LOG(WARN, "Fail to preapare scan param", K(ret)); - } else if (OB_FAIL(sstable.scan(param_, context_, range, scanner))) { + } else if (OB_FAIL(sstable.scan(query_param_for_table1_.param_, query_param_for_table1_.context_, range, scanner))) { STORAGE_LOG(WARN, "Fail to scan param", K(ret)); } return ret; } -int ObSSTableDumpErrorInfo::prepare_sstable_query_param(ObSSTable& sstable, const ObTableSchema& schema) +int ObSSTableDumpErrorInfo::prepare_sstable_query_param( + ObSSTable& sstable, const ObTableSchema& schema, QueryParam& query_param) { int ret = OB_SUCCESS; - reset(); + query_param.reset(); const uint64_t tenant_id = extract_tenant_id(schema.get_table_id()); - if (OB_FAIL(schema.get_column_ids(column_ids_, true))) { + if (OB_FAIL(schema.get_column_ids(query_param.column_ids_, true))) { STORAGE_LOG(WARN, "Fail to get column ids. ", K(ret)); - } else if (FALSE_IT(param_.out_cols_ = &column_ids_)) { - STORAGE_LOG(ERROR, "row getter", K(ret), K(column_ids_)); + } else if (FALSE_IT(query_param.param_.out_cols_ = &query_param.column_ids_)) { + STORAGE_LOG(ERROR, "row getter", K(ret), K(query_param.column_ids_)); } else { + STORAGE_LOG(INFO, "success to get column ids. ", K(ret), K(query_param.column_ids_)); ObQueryFlag query_flag(ObQueryFlag::Forward, true, /*is daily merge scan*/ true, /*is read multiple macro block*/ @@ -55,22 +57,22 @@ int ObSSTableDumpErrorInfo::prepare_sstable_query_param(ObSSTable& sstable, cons false /*is full row scan?*/, false, false); - store_ctx_.cur_pkey_ = sstable.get_partition_key(); - param_.table_id_ = schema.get_table_id(); - param_.rowkey_cnt_ = schema.get_rowkey_column_num(); - param_.schema_version_ = schema.get_schema_version(); - context_.query_flag_ = query_flag; - context_.store_ctx_ = &store_ctx_; - context_.allocator_ = &allocator_; - context_.stmt_allocator_ = &allocator_; - context_.trans_version_range_ = sstable.get_key().trans_version_range_; - context_.is_inited_ = true; // just used for dump + query_param.store_ctx_.cur_pkey_ = sstable.get_partition_key(); + query_param.param_.table_id_ = schema.get_table_id(); + query_param.param_.rowkey_cnt_ = schema.get_rowkey_column_num(); + query_param.param_.schema_version_ = schema.get_schema_version(); + query_param.context_.query_flag_ = query_flag; + query_param.context_.store_ctx_ = &query_param.store_ctx_; + query_param.context_.allocator_ = &allocator_; + query_param.context_.stmt_allocator_ = &allocator_; + query_param.context_.trans_version_range_ = sstable.get_key().trans_version_range_; + query_param.context_.is_inited_ = true; // just used for dump } return ret; } int ObSSTableDumpErrorInfo::simple_get_sstable_rowkey_get_iter( - ObSSTable& sstable, const common::ObStoreRowkey& rowkey, ObStoreRowIterator*& getter) + ObSSTable& sstable, const common::ObStoreRowkey& rowkey, QueryParam& query_param, ObStoreRowIterator*& getter) { int ret = OB_SUCCESS; getter = NULL; @@ -78,8 +80,8 @@ int ObSSTableDumpErrorInfo::simple_get_sstable_rowkey_get_iter( ext_rowkey_.get_store_rowkey() = rowkey; if (OB_FAIL(ext_rowkey_.to_collation_free_on_demand_and_cutoff_range(allocator_))) { STORAGE_LOG(WARN, "Fail to transfer rowkey", K(ret), K(ext_rowkey_)); - } else if (OB_FAIL(sstable.get(param_, context_, ext_rowkey_, getter))) { - STORAGE_LOG(WARN, "Fail to get param", K(ret), K(column_ids_)); + } else if (OB_FAIL(sstable.get(query_param.param_, query_param.context_, ext_rowkey_, getter))) { + STORAGE_LOG(WARN, "Fail to get param", K(ret), K(query_param.column_ids_)); } return ret; } @@ -101,6 +103,7 @@ int ObSSTableDumpErrorInfo::generate_projecter( STORAGE_LOG(WARN, "failed to add into map", K(ret), K(i), K(column_ids_1.at(i))); } } + STORAGE_LOG(INFO, "generate_projecter", K(ret), K(column_ids_1), K(column_ids_2)); if (OB_SUCC(ret)) { if (OB_FAIL(schema2.get_column_ids(column_ids_2))) { STORAGE_LOG(WARN, "failed to get column ids", K(ret), K(schema1)); @@ -116,7 +119,9 @@ int ObSSTableDumpErrorInfo::generate_projecter( } } if (OB_SUCC(ret) && OB_FAIL(projector.push_back(dest_pos))) { - STORAGE_LOG(WARN, "success to get from hash map", K(ret), K(i), K(column_ids_2.at(i)), K(dest_pos)); + STORAGE_LOG(WARN, "failed to push into projector", K(ret), K(i), K(column_ids_2.at(i)), K(dest_pos)); + } else { + STORAGE_LOG(INFO, "success to push into projector", K(ret), K(i), K(column_ids_2.at(i)), K(dest_pos)); } } // end for } @@ -136,7 +141,12 @@ int ObSSTableDumpErrorInfo::transform_rowkey( { int ret = OB_SUCCESS; for (int i = 0; i < rowkey_cnt; ++i) { - rowkey_obj_[i] = row.row_val_.cells_[projector.at(i)]; + if (projector.at(i) < 0) { + ret = OB_ERR_UNEXPECTED; + STORAGE_LOG(WARN, "projector is invalid", K(ret), K(i), K(rowkey_cnt), K(projector)); + } else { + rowkey_obj_[i] = row.row_val_.cells_[projector.at(i)]; + } } rowkey.assign(rowkey_obj_, rowkey_cnt); return ret; @@ -151,20 +161,20 @@ int ObSSTableDumpErrorInfo::get_row_with_rowkey_and_check(const ObStoreRow* inpu ret = OB_INVALID_ARGUMENT; STORAGE_LOG(WARN, "getter is NULL", K(ret), KPC(getter)); } else if (OB_FAIL(getter->get_next_row(ret_row))) { // get row from sstable1 - STORAGE_LOG(WARN, "failed to get row", K(ret), KPC(input_row)); + STORAGE_LOG(WARN, "failed to get row", K(ret), KPC(input_row), KPC(ret_row)); } else if (OB_ISNULL(ret_row) || !ret_row->is_valid()) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "row is invalid", K(ret), KPC(ret_row)); } else if (ObActionFlag::OP_ROW_EXIST != ret_row->flag_) { ++found_row_cnt; - STORAGE_LOG(ERROR, "found, row is not exist", KPC(input_row)); + STORAGE_LOG(ERROR, "found, row is not exist", KPC(input_row), KPC(ret_row)); } else { // check row cells for (int i = 0; i < projector.count(); ++i) { if (projector.at(i) < 0 || projector.at(i) > input_row->row_val_.count_) { // not exist } else if (ret_row->row_val_.cells_[i] != input_row->row_val_.cells_[projector.at(i)]) { ++found_row_cnt; - STORAGE_LOG(ERROR, "found, column is diffenrent", K(i), KPC(ret_row), KPC(input_row)); + STORAGE_LOG(ERROR, "found, column is diffenrent", K(i), KPC(ret_row), K(projector.at(i)), KPC(input_row)); break; } } // end of for @@ -178,62 +188,62 @@ int ObSSTableDumpErrorInfo::find_extra_row( ObSSTable& sstable1, const ObTableSchema& schema1, ObSSTable& sstable2, const ObTableSchema& schema2) { int ret = OB_SUCCESS; - ObStoreRowIterator* scanner = NULL; - ObSEArray projector; - common::ObSEArray col_descs; - int64_t found_row_cnt = 0; - int64_t iter_row_cnt = 0; - if (OB_FAIL(get_sstable_scan_iter(sstable1, schema1, scanner)) || OB_ISNULL(scanner)) { - STORAGE_LOG(WARN, "failed to get sstable scan iter", K(ret), K(sstable1), K(schema1)); - } else if (OB_FAIL(generate_projecter(schema1, schema2, projector))) { - STORAGE_LOG(WARN, "failed to generate rowkey projector", K(ret)); - } else if (OB_FAIL(schema2.get_column_ids(col_descs))) { - STORAGE_LOG(WARN, "failed to get column id array", K(ret), K(schema2)); - } else if (OB_FAIL(prepare_sstable_query_param(sstable2, schema2))) { - STORAGE_LOG(WARN, "Fail to preapare scan param", K(ret)); + if (schema1.get_virtual_column_cnt() > 0 || schema2.get_virtual_column_cnt() > 0) { + STORAGE_LOG(INFO, "schema have virtual column", K(ret)); } else { - const ObStoreRow* row_in_table1 = NULL; - ObStoreRowIterator* getter = NULL; - common::ObStoreRowkey rowkey; - const int64_t rowkey_cnt = schema2.get_rowkey_column_num(); - param_.table_id_ = schema2.get_table_id(); - param_.rowkey_cnt_ = rowkey_cnt; - while (OB_SUCC(ret)) { - if (OB_FAIL(scanner->get_next_row(row_in_table1))) { // get row from sstable1 - if (OB_ITER_END != ret) { - STORAGE_LOG(WARN, "failed to get next row", K(ret)); - } else { - STORAGE_LOG(WARN, "meet iter end", K(ret), KPC(scanner)); - ret = OB_SUCCESS; - break; + ObStoreRowIterator* scanner = NULL; + ObSEArray projector; + int64_t found_row_cnt = 0; + int64_t iter_row_cnt = 0; + if (OB_FAIL(get_sstable_scan_iter(sstable1, schema1, scanner)) || OB_ISNULL(scanner)) { + STORAGE_LOG(WARN, "failed to get sstable scan iter", K(ret), K(sstable1), K(schema1)); + } else if (OB_FAIL(generate_projecter(schema1, schema2, projector))) { + STORAGE_LOG(WARN, "failed to generate rowkey projector", K(ret)); + } else if (OB_FAIL(prepare_sstable_query_param(sstable2, schema2, query_param_for_table2_))) { + STORAGE_LOG(WARN, "Fail to preapare scan param", K(ret)); + } else { + const ObStoreRow* row_in_table1 = NULL; + ObStoreRowIterator* getter = NULL; + common::ObStoreRowkey rowkey; + const int64_t rowkey_cnt = schema2.get_rowkey_column_num(); + while (OB_SUCC(ret)) { + if (OB_FAIL(scanner->get_next_row(row_in_table1))) { // get row from sstable1 + if (OB_ITER_END != ret) { + STORAGE_LOG(WARN, "failed to get next row", K(ret)); + } else { + STORAGE_LOG(WARN, "meet iter end", K(ret), KPC(scanner)); + ret = OB_SUCCESS; + break; + } + } else if (OB_ISNULL(row_in_table1) || !row_in_table1->is_valid()) { + ret = OB_ERR_UNEXPECTED; + STORAGE_LOG(WARN, "row is invalid", K(ret), KPC(row_in_table1)); + } else if (OB_FAIL(transform_rowkey( + *row_in_table1, rowkey_cnt, projector, rowkey))) { // project into rowkey of sstable2 + STORAGE_LOG(WARN, "failed to transfor rowkey", K(ret)); + } else if (OB_FAIL(simple_get_sstable_rowkey_get_iter( + sstable2, rowkey, query_param_for_table2_, getter))) { // get row in sstable2 + STORAGE_LOG(WARN, "failed to get table getter", K(ret), KPC(getter)); + } else if (OB_FAIL(get_row_with_rowkey_and_check(row_in_table1, getter, projector, found_row_cnt))) { + STORAGE_LOG(WARN, "failed to check row", K(ret)); } - } else if (OB_ISNULL(row_in_table1) || !row_in_table1->is_valid()) { + ++iter_row_cnt; + } // end of while + } + if (OB_SUCC(ret)) { + if (found_row_cnt + sstable2.get_meta().row_count_ != sstable1.get_meta().row_count_) { ret = OB_ERR_UNEXPECTED; - STORAGE_LOG(WARN, "row is invalid", K(ret), KPC(row_in_table1)); - } else if (OB_FAIL(transform_rowkey( - *row_in_table1, rowkey_cnt, projector, rowkey))) { // project into rowkey of sstable2 - STORAGE_LOG(WARN, "failed to transfor rowkey", K(ret)); - } else if (OB_FAIL(simple_get_sstable_rowkey_get_iter(sstable2, rowkey, getter))) { // get row in sstable2 - STORAGE_LOG(WARN, "failed to get table getter", K(ret), KPC(getter)); - } else if (OB_FAIL(get_row_with_rowkey_and_check(row_in_table1, getter, projector, found_row_cnt))) { - STORAGE_LOG(WARN, "failed to check row", K(ret)); + STORAGE_LOG(WARN, "have not found all extra rows", K(ret), K(found_row_cnt), K(iter_row_cnt)); + } else { + STORAGE_LOG(ERROR, + "success to get all extra rows", + K(ret), + K(sstable1), + K(schema1), + K(sstable2), + K(schema2), + K(found_row_cnt)); } - ++iter_row_cnt; - } // end of while - } - if (OB_SUCC(ret)) { - if (found_row_cnt + sstable2.get_meta().row_count_ != sstable1.get_meta().row_count_) { - ret = OB_ERR_UNEXPECTED; - STORAGE_LOG(WARN, "have not found all extra rows", K(ret), K(found_row_cnt), K(iter_row_cnt)); - } else { - STORAGE_LOG(ERROR, - "success to get all extra rows", - K(ret), - K(sstable1), - K(schema1), - K(sstable2), - K(schema2), - K(found_row_cnt)); } } return ret; @@ -257,9 +267,8 @@ int ObSSTableDumpErrorInfo::main_and_index_row_count_error(ObSSTable& main_table void ObSSTableDumpErrorInfo::reset() { - param_.reset(); - context_.reset(); - store_ctx_.reset(); + query_param_for_table1_.reset(); + query_param_for_table2_.reset(); ext_rowkey_.reset(); } diff --git a/src/storage/ob_sstable_dump_error_info.h b/src/storage/ob_sstable_dump_error_info.h index 2409f6dc9c..6654f7059e 100644 --- a/src/storage/ob_sstable_dump_error_info.h +++ b/src/storage/ob_sstable_dump_error_info.h @@ -23,12 +23,10 @@ namespace storage { class ObSSTableDumpErrorInfo { public: ObSSTableDumpErrorInfo() - : param_(), - context_(), - store_ctx_(), - allocator_("dump_error_info"), - column_ids_(COL_ARRAY_LEN, allocator_), - ext_rowkey_() + : allocator_("dump_error_info"), + ext_rowkey_(), + query_param_for_table1_(allocator_), + query_param_for_table2_(allocator_) {} ~ObSSTableDumpErrorInfo() { @@ -44,6 +42,22 @@ public: private: static const int64_t COL_ARRAY_LEN = 128; + struct QueryParam { + QueryParam(ObIAllocator& allocator) : param_(), context_(), store_ctx_(), column_ids_(COL_ARRAY_LEN, allocator) + {} + void reset() + { + param_.reset(); + context_.reset(); + store_ctx_.reset(); + column_ids_.reuse(); + } + ObTableIterParam param_; + ObTableAccessContext context_; + ObStoreCtx store_ctx_; + ObArray column_ids_; + }; + private: int find_extra_row( ObSSTable& sstable1, const ObTableSchema& schema1, ObSSTable& sstable2, const ObTableSchema& schema2); @@ -51,20 +65,18 @@ private: const ObStoreRow& row, const int64_t rowkey_cnt, ObIArray& projector, ObStoreRowkey& rowkey); int get_sstable_scan_iter(ObSSTable& sstable, const ObTableSchema& schema, ObStoreRowIterator*& scanner); int simple_get_sstable_rowkey_get_iter( - ObSSTable& sstable, const common::ObStoreRowkey& rowkey, ObStoreRowIterator*& getter); + ObSSTable& sstable, const common::ObStoreRowkey& rowkey, QueryParam& query_param, ObStoreRowIterator*& getter); int generate_projecter(const ObTableSchema& schema1, const ObTableSchema& schema2, ObIArray& projector); int get_row_with_rowkey_and_check(const ObStoreRow* input_row, ObStoreRowIterator* getter, common::ObSEArray& projector, int64_t& found_row_cnt); - int prepare_sstable_query_param(ObSSTable& sstable, const ObTableSchema& schema); + int prepare_sstable_query_param(ObSSTable& sstable, const ObTableSchema& schema, QueryParam& query_param); private: ObObj rowkey_obj_[OB_MAX_ROWKEY_COLUMN_NUMBER]; - ObTableIterParam param_; - ObTableAccessContext context_; - ObStoreCtx store_ctx_; ObArenaAllocator allocator_; - ObArray column_ids_; ObExtStoreRowkey ext_rowkey_; + QueryParam query_param_for_table1_; + QueryParam query_param_for_table2_; }; } // namespace storage diff --git a/unittest/storage/test_new_minor_fuser.cpp b/unittest/storage/test_new_minor_fuser.cpp index 314067bc28..5b17500531 100644 --- a/unittest/storage/test_new_minor_fuser.cpp +++ b/unittest/storage/test_new_minor_fuser.cpp @@ -563,10 +563,10 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_rowkey_across_macro_blo ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var1 -10 0 3 NOP EXIST CF\n" - "0 var1 -9 -8 2 NOP EXIST CL\n" - "1 var1 -7 -14 9 6 EXIST CL\n" - "2 var2 -8 -22 5 6 EXIST CL\n"; + "0 var1 -10 0 3 NOP EXIST CF\n" + "0 var1 -9 0 2 NOP EXIST CL\n" + "1 var1 -7 0 9 6 EXIST CL\n" + "2 var2 -8 0 5 6 EXIST CL\n"; // minor mrege ObMacroBlockBuilder builder; @@ -646,12 +646,12 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_rowkey_across_macro_blo ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var1 -10 0 3 NOP EXIST CF\n" - "0 var1 -9 -8 2 NOP EXIST CL\n" - "1 var1 -7 -24 NOP 19 EXIST C\n" - "1 var1 -6 -7 NOP 2 EXIST C\n" - "1 var1 -5 -5 NOP 9 EXIST CL\n" - "2 var2 -8 -22 3 6 EXIST CL\n"; + "0 var1 -10 0 3 NOP EXIST CF\n" + "0 var1 -9 0 2 NOP EXIST CL\n" + "1 var1 -7 0 NOP 19 EXIST C\n" + "1 var1 -6 0 NOP 2 EXIST C\n" + "1 var1 -5 0 NOP 9 EXIST CL\n" + "2 var2 -8 0 3 6 EXIST CL\n"; // minor mrege ObMacroBlockBuilder builder; @@ -716,7 +716,7 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_rowkey_across_macro_blo macro_data2[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" "0 var0 -6 -16 3 NOP EXIST CL\n" - "1 var1 -12 -24 NOP 19 EXIST CF\n" + "1 var1 -12 -24 3 19 EXIST CF\n" "1 var1 -8 -22 3 6 EXIST N\n"; macro_data2[2] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" @@ -744,15 +744,15 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_rowkey_across_macro_blo const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" "0 var0 -10 0 3 7 EXIST CF\n" // two compact row need to compact together - "0 var0 -9 -24 NOP 19 EXIST N\n" - "0 var0 -8 -22 3 6 EXIST N\n" - "0 var0 -6 -16 3 7 EXIST CL\n" - "1 var1 -12 -24 NOP 19 EXIST CF\n" - "1 var1 -8 -22 3 6 EXIST N\n" - "1 var1 -7 -15 3 6 EXIST C\n" - "1 var1 -6 -7 NOP 2 EXIST C\n" - "1 var1 -5 -5 NOP 9 EXIST CL\n" - "2 var2 -8 -22 5 6 EXIST CL\n"; + "0 var0 -9 0 NOP 19 EXIST N\n" + "0 var0 -8 0 3 6 EXIST N\n" + "0 var0 -6 0 3 7 EXIST CL\n" + "1 var1 -12 0 3 19 EXIST CF\n" + "1 var1 -8 0 3 6 EXIST C\n" + "1 var1 -7 0 3 6 EXIST C\n" + "1 var1 -6 0 NOP 2 EXIST C\n" + "1 var1 -5 0 NOP 9 EXIST CL\n" + "2 var2 -8 0 5 6 EXIST CL\n"; // minor mrege @@ -839,12 +839,12 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_multi_sstable) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -1 -9 7 NOP EXIST CLF\n" - "1 var1 -12 0 5 19 EXIST CF\n" - "1 var1 -7 -24 5 21 EXIST C\n" - "1 var1 -4 0 5 2 EXIST CL\n" - "2 var2 -9 -22 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST CL\n"; + "0 var0 -1 0 7 NOP EXIST CLF\n" + "1 var1 -12 0 5 19 EXIST CF\n" + "1 var1 -7 0 5 21 EXIST C\n" + "1 var1 -4 0 5 2 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -913,7 +913,7 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_multi_sstable2) ObSSTable sstable3; const char* macro_data3[1]; macro_data3[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "1 var1 -12 0 NOP 19 EXIST CF\n" + "1 var1 -12 0 1 19 EXIST CF\n" "1 var1 -8 -2 1 6 EXIST N\n" "1 var1 -7 -35 7 NOP EXIST L\n" "2 var2 -9 -25 18 NOP EXIST CLF\n"; @@ -935,13 +935,13 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_multi_sstable2) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" - "1 var1 -12 0 NOP 19 EXIST CF\n" - "1 var1 -8 -2 1 6 EXIST N\n" - "1 var1 -7 -35 7 19 EXIST C\n" - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "0 var0 -9 0 9 12 EXIST CL\n" + "1 var1 -12 0 1 19 EXIST CF\n" + "1 var1 -8 0 1 6 EXIST N\n" + "1 var1 -7 0 7 19 EXIST N\n" + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -1044,13 +1044,13 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_multi_sstable3) const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" - "1 var1 -12 0 18 19 EXIST CF\n" // two compact rows with same rowkey & diff - // trans_version need compact - "1 var1 -8 -2 1 6 EXIST N\n" - "1 var1 -7 -35 18 7 EXIST CL\n" - "2 var2 -9 -25 18 9 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "0 var0 -9 0 9 12 EXIST CL\n" + "1 var1 -12 0 18 19 EXIST CF\n" // two compact rows with same rowkey & diff + // trans_version need compact + "1 var1 -8 0 1 6 EXIST N\n" + "1 var1 -7 0 18 7 EXIST CL\n" + "2 var2 -9 0 18 9 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -1137,9 +1137,9 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_multi_sstable_has_same_row) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -9 7 12 EXIST CL\n" - "1 var1 -7 -24 18 6 EXIST CL\n" - "2 var2 -9 -5 1 9 EXIST CL\n"; + "0 var0 -9 0 7 12 EXIST CL\n" + "1 var1 -7 0 18 6 EXIST CL\n" + "2 var2 -9 0 1 9 EXIST CL\n"; // minor mrege @@ -1229,11 +1229,11 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_new_sstable_had_old_rows) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -9 7 12 EXIST CL\n" - "1 var1 -12 0 7 6 EXIST CF\n" - "1 var1 -7 -24 18 6 EXIST C\n" - "1 var1 -2 0 21 12 EXIST CL\n" - "2 var2 -9 -5 1 9 EXIST CL\n"; + "0 var0 -9 0 7 12 EXIST CL\n" + "1 var1 -12 0 7 6 EXIST CF\n" + "1 var1 -7 0 18 6 EXIST C\n" + "1 var1 -2 0 21 12 EXIST CL\n" + "2 var2 -9 0 1 9 EXIST CL\n"; // minor mrege @@ -1323,12 +1323,12 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_new_sstable_had_old_rows2) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -14 -19 71 12 EXIST C\n" - "0 var0 -9 -9 7 12 EXIST CL\n" - "1 var1 -7 -24 21 68 EXIST C\n" - "1 var1 -6 0 21 NOP EXIST N\n" - "1 var1 -4 0 91 12 EXIST L\n" - "2 var2 -9 -5 1 9 EXIST CL\n"; + "0 var0 -14 0 71 12 EXIST C\n" + "0 var0 -9 0 7 12 EXIST CL\n" + "1 var1 -7 0 21 68 EXIST C\n" + "1 var1 -6 0 21 NOP EXIST N\n" + "1 var1 -4 0 91 12 EXIST CL\n" + "2 var2 -9 0 1 9 EXIST CL\n"; // minor mrege @@ -1418,12 +1418,12 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_delete_row) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -14 -19 71 12 EXIST C\n" - "0 var0 -9 -9 7 12 EXIST CL\n" - "1 var1 -7 -24 NOP NOP DELETE C\n" - "1 var1 -6 0 21 NOP EXIST N\n" - "1 var1 -4 0 91 12 EXIST L\n" - "2 var2 -9 -5 1 9 EXIST CL\n"; + "0 var0 -14 0 71 12 EXIST C\n" + "0 var0 -9 0 7 12 EXIST CL\n" + "1 var1 -7 0 NOP NOP DELETE C\n" + "1 var1 -6 0 21 NOP EXIST N\n" + "1 var1 -4 0 91 12 EXIST CL\n" + "2 var2 -9 0 1 9 EXIST CL\n"; // minor mrege @@ -1513,10 +1513,10 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_test_allocator) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint var var flag multi_version_row_flag\n" - "0 var0 -14 -19 bbbbb huluhulu EXIST C\n" - "0 var0 -9 -9 biubiu huluhulu EXIST CL\n" - "1 var1 -7 -24 char77 kkkkk3 EXIST CL\n" - "2 var2 -9 -5 1 nnnnn EXIST CL\n"; + "0 var0 -14 0 bbbbb huluhulu EXIST C\n" + "0 var0 -9 0 biubiu huluhulu EXIST CL\n" + "1 var1 -7 0 char77 kkkkk3 EXIST CL\n" + "2 var2 -9 0 1 nnnnn EXIST CL\n"; // minor mrege @@ -1618,10 +1618,10 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_test_allocator2) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint var var flag multi_version_row_flag\n" - "0 var0 -14 -39 bbbbb akhgfajkhg EXIST C\n" - "0 var0 -9 -9 biubiu huluhulu EXIST CL\n" - "1 var1 -7 -40 qjkfjkqhgkq hkgqhjkgqhkghqkhgkqh EXIST CL\n" - "2 var2 -9 -5 1 nnnnn EXIST CL\n"; + "0 var0 -14 0 bbbbb akhgfajkhg EXIST C\n" + "0 var0 -9 0 biubiu huluhulu EXIST CL\n" + "1 var1 -7 0 qjkfjkqhgkq hkgqhjkgqhkghqkhgkqh EXIST CL\n" + "2 var2 -9 0 1 nnnnn EXIST CL\n"; // minor mrege @@ -1722,7 +1722,7 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_uncommitted_row_running ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" + "0 var0 -9 0 9 12 EXIST CL\n" "1 var1 MIN -35 7 NOP EXIST U\n" "1 var1 MIN -26 NOP 11 EXIST U\n" "1 var1 MIN -24 NOP 19 EXIST U\n" @@ -1731,8 +1731,8 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_uncommitted_row_running "1 var1 MIN -7 NOP 2 EXIST U\n" "1 var1 MIN -6 NOP 2 EXIST U\n" "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -1836,10 +1836,10 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_uncommitted_row_abort) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" + "0 var0 -9 0 9 12 EXIST CL\n" "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST CL\n"; + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege scan_trans_part_ctx_.clear_all(); @@ -1941,11 +1941,11 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_uncommitted_row_commit) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" - "1 var1 -18 -35 7 11 EXIST C\n" - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "0 var0 -9 0 9 12 EXIST CL\n" + "1 var1 -18 0 7 11 EXIST C\n" + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2043,11 +2043,11 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_uncommitted_row_commit2 ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CL\n" - "1 var1 -18 -12 7 6 EXIST C\n" - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "0 var0 -9 0 9 12 EXIST CL\n" + "1 var1 -18 0 7 6 EXIST C\n" + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2123,8 +2123,8 @@ TEST_F(TestNewMinorFuserMerge, test_new_minor_fuser_with_multi_delete_row) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "1 var1 -40 -12 27 NOP EXIST C\n" - "1 var1 -18 -10 NOP NOP DELETE C\n" + "1 var1 -40 0 27 NOP EXIST C\n" + "1 var1 -18 0 NOP NOP DELETE C\n" "1 var1 -4 0 NOP 9 EXIST CL\n"; // minor mrege diff --git a/unittest/storage/test_partition_merge_multi_version.cpp b/unittest/storage/test_partition_merge_multi_version.cpp index a706dda670..0c0021ead2 100644 --- a/unittest/storage/test_partition_merge_multi_version.cpp +++ b/unittest/storage/test_partition_merge_multi_version.cpp @@ -1989,13 +1989,13 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -16 8 NOP EXIST U\n" "1 var1 MIN -12 NOP NOP EXIST U\n" - "1 var1 -24 -10 7 6 EXIST C\n" - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -24 0 7 6 EXIST C\n" + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2101,13 +2101,13 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans2) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -89 NOP 9 EXIST U\n" // trans_id_3 - "1 var1 -24 -17 7 12 EXIST C\n" // trans_id_2 - "1 var1 -16 -10 7 6 EXIST C\n" // trans_id_1 - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -24 0 7 12 EXIST C\n" // trans_id_2 + "1 var1 -16 0 7 6 EXIST C\n" // trans_id_1 + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2224,15 +2224,15 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans_can_compact) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -89 NOP 9 EXIST U\n" // trans_id_5 - "1 var1 -35 -17 7 12 EXIST C\n" // trans_id_4 - "1 var1 -29 -13 NOP 28 EXIST N\n" // trans_id_3 - "1 var1 -24 -12 NOP 71 EXIST N\n" // trans_id_2 - "1 var1 -16 -10 7 6 EXIST C\n" // trans_id_1 - "1 var1 -4 0 NOP 9 EXIST L\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -35 0 7 12 EXIST C\n" // trans_id_4 + "1 var1 -29 0 NOP 28 EXIST N\n" // trans_id_3 + "1 var1 -24 0 NOP 71 EXIST N\n" // trans_id_2 + "1 var1 -16 0 7 6 EXIST C\n" // trans_id_1 + "1 var1 -4 0 NOP 9 EXIST L\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2269,10 +2269,10 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans_can_compact2) "0 var0 -9 -9 7 12 EXIST CL\n"; macro_data[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" - "1 var1 MIN -14 NOP 59 EXIST U trans_id_4\n"; + "1 var1 MIN -14 NOP 59 EXIST U trans_id_2\n"; macro_data[2] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" - "1 var1 MIN2 -13 81 28 EXIST U trans_id_3\n"; + "1 var1 MIN2 -13 81 28 EXIST U trans_id_2\n"; macro_data[3] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" "1 var1 MIN2 -12 NOP 71 EXIST U trans_id_2\n" @@ -2349,16 +2349,14 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans_can_compact2) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -89 NOP 9 EXIST U\n" // trans_id_5 - "1 var1 -35 -17 81 12 EXIST C\n" // trans_id_4 - "1 var1 -29 -13 81 28 EXIST C\n" // trans_id_3 - "1 var1 -24 -12 NOP 71 EXIST N\n" // trans_id_2 - "1 var1 -16 -10 NOP 6 EXIST N\n" // trans_id_1 - "1 var1 -16 -7 7 2 EXIST C\n" - "1 var1 -4 0 NOP 9 EXIST L\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -35 0 81 12 EXIST C\n" // trans_id_4 + "1 var1 -24 0 81 59 EXIST C\n" // trans_id_2 + "1 var1 -16 0 7 6 EXIST C\n" // trans_id_1 + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2478,16 +2476,16 @@ TEST_F(TestMultiVersionMerge, test_merge_with_multi_trans_can_not_compact) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -93 NOP 17 EXIST U\n" // trans_id_6 - "1 var1 -61 -91 NOP 72 EXIST C\n" // trans_id_5 - "1 var1 -35 -17 NOP 12 EXIST C\n" // trans_id_4 - "1 var1 -29 -13 NOP 28 EXIST N\n" // trans_id_3 - "1 var1 -24 -12 NOP 71 EXIST N\n" // trans_id_2 - "1 var1 -16 -10 NOP 6 EXIST C\n" // trans_id_1 - "1 var1 -4 0 NOP 9 EXIST L\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -61 0 NOP 72 EXIST C\n" // trans_id_5 + "1 var1 -35 0 NOP 12 EXIST C\n" // trans_id_4 + "1 var1 -29 0 NOP 28 EXIST N\n" // trans_id_3 + "1 var1 -24 0 NOP 71 EXIST N\n" // trans_id_2 + "1 var1 -16 0 NOP 6 EXIST C\n" // trans_id_1 + "1 var1 -4 0 NOP 9 EXIST L\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -2584,10 +2582,10 @@ TEST_F(TestMultiVersionMerge, test_merge_with_same_sql_sequence) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "1 var1 -35 -14 18 59 EXIST C\n" // trans_id_4 - "1 var1 -29 -13 NOP 28 EXIST N\n" // trans_id_3 - "1 var1 -24 -12 NOP 71 EXIST N\n" // trans_id_2 - "1 var1 -16 -10 18 6 EXIST CL\n"; // trans_id_1 + "1 var1 -35 0 18 59 EXIST C\n" // trans_id_4 + "1 var1 -29 0 NOP 28 EXIST N\n" // trans_id_3 + "1 var1 -24 0 NOP 71 EXIST N\n" // trans_id_2 + "1 var1 -16 0 18 6 EXIST CL\n"; // trans_id_1 // minor mrege @@ -2686,8 +2684,8 @@ TEST_F(TestMultiVersionMerge, test_merge_with_magic_row) const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" "1 var1 MAGIC MAGIC NOP NOP EXIST LM\n" - "2 var2 -92 -71 18 1 EXIST C\n" // trans_id_4 - "2 var2 -29 -9 18 0 EXIST CL\n"; // trans_id_2 + "2 var2 -92 0 18 1 EXIST C\n" // trans_id_4 + "2 var2 -29 0 18 0 EXIST CL\n"; // trans_id_2 // minor mrege @@ -2810,8 +2808,8 @@ TEST_F(TestMultiVersionMerge, test_merge_with_magic_row2) const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" "1 var1 -39 0 18 59 EXIST CF\n" "1 var1 -29 0 18 59 EXIST C \n" - "1 var1 -1 -6 18 2 EXIST CL \n" - "2 var2 -92 -71 18 1 EXIST CLF\n"; + "1 var1 -1 0 18 2 EXIST CL \n" + "2 var2 -92 0 18 1 EXIST CLF\n"; // minor mrege @@ -2935,7 +2933,7 @@ TEST_F(TestMultiVersionMerge, test_merge_with_magic_row3) "1 var1 -39 0 18 59 EXIST CF\n" "1 var1 -29 0 18 59 EXIST C \n" "1 var1 -12 0 20 59 EXIST CL \n" - "2 var2 -92 -71 18 1 EXIST CLF\n"; + "2 var2 -92 0 18 1 EXIST CLF\n"; // minor mrege @@ -3134,12 +3132,12 @@ TEST_F(TestMultiVersionMerge, test_sstable_merge_cut_with_multi_trans) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 9 12 EXIST CLF\n" + "0 var0 -9 0 9 12 EXIST CLF\n" "1 var1 MIN -16 8 NOP EXIST U\n" "1 var1 MIN -12 NOP NOP EXIST U\n" - "1 var1 -4 0 NOP 9 EXIST CL\n" - "2 var2 -9 -25 18 7 EXIST CF\n" - "2 var2 -4 -15 NOP 7 EXIST L\n"; + "1 var1 -4 0 NOP 9 EXIST CL\n" + "2 var2 -9 0 18 7 EXIST CF\n" + "2 var2 -4 0 NOP 7 EXIST CL\n"; // minor mrege @@ -3219,8 +3217,8 @@ TEST_F(TestMultiVersionMerge, test_trans_cross_sstable) ObExtStoreRange range; const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" - "0 var0 -9 -11 NOP NOP DELETE CLF\n" - "1 var1 -38 -0 -1 -20 EXIST CLF\n"; + "0 var0 -9 0 NOP NOP DELETE CLF\n" + "1 var1 -38 0 -1 -20 EXIST CLF\n"; // minor mrege @@ -3245,7 +3243,7 @@ TEST_F(TestMultiVersionMerge, test_trans_cross_sstable) } } -TEST_F(TestMultiVersionMerge, test_merge_with_dml) +TEST_F(TestMultiVersionMerge, test_trans_cross_sstable_and_first_is_delete_row) { GCONF._enable_sparse_row = false; ObMemtableCtxFactory mem_ctx; @@ -3253,39 +3251,36 @@ TEST_F(TestMultiVersionMerge, test_merge_with_dml) const int64_t rowkey_cnt = TEST_ROWKEY_COLUMN_CNT + ObMultiVersionRowkeyHelpper::get_extra_rowkey_col_cnt(); storage::ObTablesHandle tables_handle; ObSSTable sstable1; - const char *macro_data[1]; - macro_data[0] = - "bigint var bigint bigint bigint bigint dml flag multi_version_row_flag trans_id\n" - "1 var1 MIN -28 NOP NOP T_DML_DELETE DELETE LU trans_id_1\n" - "2 var2 MIN -10 NOP NOP T_DML_DELETE DELETE LU trans_id_1\n" - "3 var3 MIN -21 NOP NOP T_DML_LOCK EXIST LU trans_id_1\n" - "4 var4 MIN -71 18 28 T_DML_INSERT EXIST U trans_id_1\n" - "4 var4 MIN -12 NOP NOP T_DML_DELETE EXIST LU trans_id_1\n" - "5 var5 MIN -18 NOP NOP T_DML_LOCK EXIST LU trans_id_1\n"; + const char* macro_data[4]; + macro_data[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" + "1 var1 MIN -12 -1 -20 DELETE U trans_id_1\n" + "1 var1 MIN -10 NOP 6 EXIST U trans_id_1\n"; + macro_data[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" + "1 var1 MIN -7 NOP 2 EXIST U trans_id_1\n" + "1 var1 MIN -6 7 2 EXIST LU trans_id_1\n"; prepare_data_start(sstable1, macro_data, rowkey_cnt, 9, "none", FLAT_ROW_STORE, 0); prepare_one_macro(macro_data, 1); + prepare_one_macro(¯o_data[1], 1, INT64_MAX, nullptr, nullptr, true); prepare_data_end(sstable1); ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable1)); + STORAGE_LOG(INFO, "finish prepare sstable1"); ObSSTable sstable2; - const char *macro_data2[1]; - macro_data2[0] = "bigint var bigint bigint bigint bigint dml flag multi_version_row_flag trans_id\n" - "6 var6 MIN -18 NOP NOP T_DML_LOCK EXIST LU trans_id_1\n"; + const char* macro_data2[1]; + macro_data2[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag trans_id\n" + "1 var1 -38 0 NOP NOP DELETE CLF trans_id_0\n"; prepare_data_start(sstable2, macro_data2, rowkey_cnt, 10, "none", FLAT_ROW_STORE, 0); prepare_one_macro(macro_data2, 1); prepare_data_end(sstable2); ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable2)); STORAGE_LOG(INFO, "finish prepare sstable2"); - - // make all trans running int ret = OB_SUCCESS; test_trans_part_ctx_.clear_all(); - if (OB_FAIL(test_trans_part_ctx_.add_transaction_status( - transaction::ObTransTableStatusType::COMMIT, 29))) { + if (OB_FAIL(test_trans_part_ctx_.add_transaction_status(transaction::ObTransTableStatusType::COMMIT, 38))) { STORAGE_LOG(ERROR, "add transaction status failed", K(ret)); } @@ -3295,24 +3290,197 @@ TEST_F(TestMultiVersionMerge, test_merge_with_dml) trans_version_range.base_version_ = 1; prepare_merge_context(tables_handle, MINI_MINOR_MERGE, false, trans_version_range, merge_context); + context_.query_flag_.is_sstable_cut_ = true; ObMockIterator res_iter; - ObStoreRowIterator *scanner = NULL; + ObStoreRowIterator* scanner = NULL; ObExtStoreRange range; - const char *result1 = - "bigint var bigint bigint bigint bigint dml flag multi_version_row_flag\n" - "1 var1 -29 -28 NOP NOP T_DML_DELETE DELETE CL\n" - "2 var2 -29 -10 NOP NOP T_DML_DELETE DELETE CL\n" - "3 var3 -29 -21 NOP NOP T_DML_LOCK EXIST CL\n" - "4 var4 -29 -71 18 28 T_DML_INSERT EXIST CL\n" - "5 var5 -29 -18 NOP NOP T_DML_LOCK EXIST CL\n" - "6 var6 -29 -18 NOP NOP T_DML_LOCK EXIST CL\n"; + const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -38 0 NOP NOP DELETE CLF\n"; // minor mrege ObMacroBlockBuilder builder; - ObSSTable *merged_sstable = nullptr; - ASSERT_EQ(OB_SUCCESS, ObPartitionMergeUtil::merge_partition(&mem_ctx, merge_context, builder, 0)); + ObSSTable* merged_sstable = nullptr; + ASSERT_EQ(OB_SUCCESS, ObPartitionMergeUtil::merge_partition(&mem_ctx, merge_context, builder, 0)); + build_sstable(merge_context, merged_sstable); + + res_iter.reset(); + range.get_range().set_whole_range(); + prepare_query_param(trans_version_range); + context_.query_flag_.is_sstable_cut_ = true; + ASSERT_EQ(OB_SUCCESS, range.to_collation_free_range_on_demand_and_cutoff_range(allocator_)); + if (OB_NOT_NULL(merged_sstable)) { + context_.read_out_type_ = FLAT_ROW_STORE; + ASSERT_EQ(OB_SUCCESS, merged_sstable->scan(param_, context_, range, scanner)); + ASSERT_EQ(OB_SUCCESS, res_iter.from(result1)); + ASSERT_TRUE(res_iter.equals(*scanner, true)); + scanner->~ObStoreRowIterator(); + } else { + STORAGE_LOG(ERROR, "merged_sstable is null"); + } +} +/* +TEST_F(TestMultiVersionMerge, test_trans_cross_sstable_check_flag_bug) +{ + GCONF._enable_sparse_row = false; + ObMemtableCtxFactory mem_ctx; + ObSSTableMergeCtx merge_context; + const int64_t rowkey_cnt = TEST_ROWKEY_COLUMN_CNT + ObMultiVersionRowkeyHelpper::get_extra_rowkey_col_cnt(); + storage::ObTablesHandle tables_handle; + ObSSTable sstable1; + const char* macro_data[2]; + macro_data[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -40 0 -1 -20 EXIST CF\n" + "1 var1 -30 0 NOP 6 EXIST N\n"; + + macro_data[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -28 0 NOP 2 EXIST N\n" + "1 var1 -26 0 7 NOP EXIST L\n"; + + prepare_data_start(sstable1, macro_data, rowkey_cnt, 9, "none", FLAT_ROW_STORE, 0); + prepare_one_macro(macro_data, 1); + prepare_one_macro(¯o_data[1], 1, INT64_MAX, nullptr, nullptr, true); + prepare_data_end(sstable1); + ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable1)); + + STORAGE_LOG(INFO, "finish prepare sstable1"); + + ObSSTable sstable2; + const char* macro_data2[2]; + macro_data2[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -49 0 8 NOP EXIST CF\n"; + + macro_data2[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -46 0 18 NOP EXIST L\n"; + + prepare_data_start(sstable2, macro_data2, rowkey_cnt, 9, "none", FLAT_ROW_STORE, 0); + prepare_one_macro(macro_data2, 1); + prepare_one_macro(¯o_data2[1], 1, INT64_MAX, nullptr, nullptr, true); + prepare_data_end(sstable2); + ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable2)); + STORAGE_LOG(INFO, "finish prepare sstable2"); + + ObSSTable sstable3; + const char* macro_data3[2]; + macro_data3[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -52 0 90 NOP EXIST CF\n"; + + macro_data3[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -49 0 26 NOP EXIST L\n"; + + prepare_data_start(sstable3, macro_data3, rowkey_cnt, 9, "none", FLAT_ROW_STORE, 0); + prepare_one_macro(macro_data3, 1); + prepare_one_macro(¯o_data3[1], 1, INT64_MAX, nullptr, nullptr, true); + prepare_data_end(sstable3); + ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable3)); + STORAGE_LOG(INFO, "finish prepare sstable2"); + + int ret = OB_SUCCESS; + test_trans_part_ctx_.clear_all(); + + ObVersionRange trans_version_range; + trans_version_range.snapshot_version_ = 100; + trans_version_range.multi_version_start_ = 1; + trans_version_range.base_version_ = 1; + + prepare_merge_context(tables_handle, MINI_MINOR_MERGE, false, trans_version_range, merge_context); + ObMockIterator res_iter; + ObStoreRowIterator* scanner = NULL; + ObExtStoreRange range; + + const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -52 0 90 -20 EXIST CF\n" + "1 var1 -49 0 26 NOP EXIST N\n" + "1 var1 -46 0 18 NOP EXIST N\n" + "1 var1 -40 0 -1 -20 EXIST C\n" + "1 var1 -30 0 NOP 6 EXIST N\n" + "1 var1 -28 0 7 2 EXIST C\n" + "1 var1 -26 0 7 NOP EXIST L\n"; + + // minor mrege + + ObMacroBlockBuilder builder; + ObSSTable* merged_sstable = nullptr; + ASSERT_EQ(OB_SUCCESS, ObPartitionMergeUtil::merge_partition(&mem_ctx, merge_context, builder, 0)); + build_sstable(merge_context, merged_sstable); + + res_iter.reset(); + range.get_range().set_whole_range(); + prepare_query_param(trans_version_range); + context_.query_flag_.is_sstable_cut_ = true; + ASSERT_EQ(OB_SUCCESS, range.to_collation_free_range_on_demand_and_cutoff_range(allocator_)); + if (OB_NOT_NULL(merged_sstable)) { + context_.read_out_type_ = FLAT_ROW_STORE; + ASSERT_EQ(OB_SUCCESS, merged_sstable->scan(param_, context_, range, scanner)); + ASSERT_EQ(OB_SUCCESS, res_iter.from(result1)); + ASSERT_TRUE(res_iter.equals(*scanner, true)); + scanner->~ObStoreRowIterator(); + } else { + STORAGE_LOG(ERROR, "merged_sstable is null"); + } +} +*/ +TEST_F(TestMultiVersionMerge, test_nop_pos_check_with_del_row) +{ + GCONF._enable_sparse_row = false; + ObMemtableCtxFactory mem_ctx; + ObSSTableMergeCtx merge_context; + const int64_t rowkey_cnt = TEST_ROWKEY_COLUMN_CNT + ObMultiVersionRowkeyHelpper::get_extra_rowkey_col_cnt(); + storage::ObTablesHandle tables_handle; + ObSSTable sstable1; + const char* macro_data[2]; + macro_data[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -10 0 NOP NOP DELETE CLF\n" + "2 var2 -17 0 NOP 6 EXIST CLF\n"; + + macro_data[1] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "3 var3 -19 0 NOP 2 EXIST CLF\n"; + + prepare_data_start(sstable1, macro_data, rowkey_cnt, 9, "none", FLAT_ROW_STORE, 0); + prepare_one_macro(macro_data, 1); + prepare_one_macro(¯o_data[1], 1, INT64_MAX, nullptr, nullptr, true); + prepare_data_end(sstable1); + ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable1)); + + STORAGE_LOG(INFO, "finish prepare sstable1"); + + ObSSTable sstable2; + const char* macro_data2[1]; + macro_data2[0] = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -38 0 NOP 18 EXIST CLF\n" + "2 var2 -29 0 82 3 EXIST CLF\n"; + + prepare_data_start(sstable2, macro_data2, rowkey_cnt, 10, "none", FLAT_ROW_STORE, 0); + prepare_one_macro(macro_data2, 1); + prepare_data_end(sstable2); + ASSERT_EQ(OB_SUCCESS, tables_handle.add_table(&sstable2)); + STORAGE_LOG(INFO, "finish prepare sstable2"); + int ret = OB_SUCCESS; + + ObVersionRange trans_version_range; + trans_version_range.snapshot_version_ = 100; + trans_version_range.multi_version_start_ = 1; + trans_version_range.base_version_ = 1; + + prepare_merge_context(tables_handle, MINI_MINOR_MERGE, false, trans_version_range, merge_context); + context_.query_flag_.is_sstable_cut_ = true; + ObMockIterator res_iter; + ObStoreRowIterator* scanner = NULL; + ObExtStoreRange range; + + const char* result1 = "bigint var bigint bigint bigint bigint flag multi_version_row_flag\n" + "1 var1 -38 0 NOP 18 EXIST CF\n" + "1 var1 -10 0 NOP NOP DELETE CL\n" + "2 var2 -29 0 82 3 EXIST CF\n" + "2 var2 -17 0 NOP 6 EXIST CL\n" + "3 var3 -19 0 NOP 2 EXIST CLF\n"; + + // minor mrege + + ObMacroBlockBuilder builder; + ObSSTable* merged_sstable = nullptr; + ASSERT_EQ(OB_SUCCESS, ObPartitionMergeUtil::merge_partition(&mem_ctx, merge_context, builder, 0)); build_sstable(merge_context, merged_sstable); res_iter.reset(); -- GitLab