From 406d31f5f2879557b03453787c458a94fa3b6e9d Mon Sep 17 00:00:00 2001 From: godyangfight Date: Wed, 8 May 2024 04:04:01 +0000 Subject: [PATCH] Fix check sstable version range continues bug. --- .../high_availability/ob_transfer_struct.cpp | 2 +- src/storage/tablet/ob_tablet_table_store.cpp | 19 ++++------ src/storage/tablet/ob_tablet_table_store.h | 2 +- unittest/storage/test_compaction_policy.cpp | 37 +++++++++++++++++++ 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/storage/high_availability/ob_transfer_struct.cpp b/src/storage/high_availability/ob_transfer_struct.cpp index 147e7bdfd..a40d0087d 100644 --- a/src/storage/high_availability/ob_transfer_struct.cpp +++ b/src/storage/high_availability/ob_transfer_struct.cpp @@ -477,7 +477,7 @@ int ObTXTransferUtils::build_empty_minor_sstable_param_( param.data_checksum_ = 0; param.occupy_size_ = 0; param.ddl_scn_.set_min(); - param.filled_tx_scn_.set_min(); + param.filled_tx_scn_ = end_scn; param.original_size_ = 0; param.compressor_type_ = ObCompressorType::NONE_COMPRESSOR; diff --git a/src/storage/tablet/ob_tablet_table_store.cpp b/src/storage/tablet/ob_tablet_table_store.cpp index 9489d08b9..562a5d9fc 100644 --- a/src/storage/tablet/ob_tablet_table_store.cpp +++ b/src/storage/tablet/ob_tablet_table_store.cpp @@ -2274,30 +2274,25 @@ int ObTabletTableStore::cut_ha_sstable_scn_range_( int ObTabletTableStore::check_minor_table_continue_( ObITable *table, - ObITable *prev_table) const + ObITable *&prev_table) const { int ret = OB_SUCCESS; ObSSTable *curr_sstable = nullptr; - ObSSTable *prev_sstable = nullptr; + if (OB_UNLIKELY(OB_ISNULL(table) || !table->is_multi_version_minor_sstable())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table must be multi version minor table", K(ret), KPC(table)); } else if (OB_ISNULL(prev_table)) { - // do nothing + //do nothing } else if (table->get_start_scn() > prev_table->get_end_scn() || table->get_end_scn() <= prev_table->get_end_scn()) { ret = OB_ERR_SYS; LOG_ERROR("table scn range not continuous or overlap", K(ret), KPC(table), KPC(prev_table)); - } else if (FALSE_IT(curr_sstable = static_cast(table))) { - } else if (FALSE_IT(prev_sstable = static_cast(prev_table))) { - } else if (table->get_key().tablet_id_.is_ls_inner_tablet() || prev_sstable->get_filled_tx_scn().is_max()) { - // do nothing - } else if (curr_sstable->get_filled_tx_scn() < prev_sstable->get_filled_tx_scn()) { - ret = OB_ERR_SYS; - LOG_WARN("sstable's filled_tx_scn is out of order", K(ret), KPC(table), KP(prev_table), - "curr_filled_tx_scn", curr_sstable->get_filled_tx_scn(), "prev_filled_tx_scn", prev_sstable->get_filled_tx_scn()); } - prev_table = table; + + if (OB_SUCC(ret)) { + prev_table = table; + } return ret; } diff --git a/src/storage/tablet/ob_tablet_table_store.h b/src/storage/tablet/ob_tablet_table_store.h index d00cfb8d0..353ec2425 100644 --- a/src/storage/tablet/ob_tablet_table_store.h +++ b/src/storage/tablet/ob_tablet_table_store.h @@ -308,7 +308,7 @@ private: ObITable **minor_sstables) const; int check_minor_table_continue_( ObITable *table, - ObITable *prev_table) const; + ObITable *&prev_table) const; int combine_ha_minor_sstables_( const ObTablet &tablet, common::ObIArray &old_store_minor_sstables, diff --git a/unittest/storage/test_compaction_policy.cpp b/unittest/storage/test_compaction_policy.cpp index 640ef5204..f2a0aa546 100644 --- a/unittest/storage/test_compaction_policy.cpp +++ b/unittest/storage/test_compaction_policy.cpp @@ -1096,6 +1096,43 @@ TEST_F(TestCompactionPolicy, test_minor_dag_intersect) ASSERT_EQ(false, (dag1 == dag2)); } + +TEST_F(TestCompactionPolicy, check_sstable_continue_failed) +{ + int ret = OB_SUCCESS; + ObTenantFreezeInfoMgr *mgr = MTL(ObTenantFreezeInfoMgr *); + ASSERT_TRUE(nullptr != mgr); + + common::ObArray freeze_info; + share::SCN frozen_val; + frozen_val.val_ = 1; + ASSERT_EQ(OB_SUCCESS, freeze_info.push_back(share::ObFreezeInfo(frozen_val, 1, 0))); + + ret = TestCompactionPolicy::prepare_freeze_info(500, freeze_info); + + ASSERT_EQ(OB_SUCCESS, ret); + + const char *key_data = + "table_type start_scn end_scn max_ver upper_ver\n" + "10 0 1 1 1 \n" + "11 1 150 150 150 \n" + "11 150 200 200 200 \n" + "11 200 250 250 250 \n" + "11 250 300 300 300 \n" + "11 900 1000 1000 1000 \n"; + + ret = prepare_tablet(key_data, 1000, 1000); + ASSERT_EQ(OB_SUCCESS, ret); + + ObTablet *tablet = tablet_handle_.get_obj(); + ASSERT_TRUE(nullptr != tablet); + ObTabletMemberWrapper table_store_wrapper; + ret = tablet->fetch_table_store(table_store_wrapper); + ASSERT_EQ(OB_SUCCESS, ret); + ret = table_store_wrapper.get_member()->check_continuous(); + ASSERT_EQ(OB_ERR_SYS, ret); +} + } //unittest } //oceanbase