Fix tablet table store check sstable continue bug.
This commit is contained in:
		@ -477,7 +477,7 @@ int ObTXTransferUtils::build_empty_minor_sstable_param_(
 | 
				
			|||||||
    param.data_checksum_ = 0;
 | 
					    param.data_checksum_ = 0;
 | 
				
			||||||
    param.occupy_size_ = 0;
 | 
					    param.occupy_size_ = 0;
 | 
				
			||||||
    param.ddl_scn_.set_min();
 | 
					    param.ddl_scn_.set_min();
 | 
				
			||||||
    param.filled_tx_scn_.set_min();
 | 
					    param.filled_tx_scn_ = end_scn;
 | 
				
			||||||
    param.original_size_ = 0;
 | 
					    param.original_size_ = 0;
 | 
				
			||||||
    param.compressor_type_ = ObCompressorType::NONE_COMPRESSOR;
 | 
					    param.compressor_type_ = ObCompressorType::NONE_COMPRESSOR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1902,9 +1902,10 @@ int ObTabletTableStore::check_minor_tables_continue_(T &minor_tables) const
 | 
				
			|||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  ObITable *prev_table = nullptr;
 | 
					  ObITable *prev_table = nullptr;
 | 
				
			||||||
  prev_table = nullptr;
 | 
					  prev_table = nullptr;
 | 
				
			||||||
 | 
					  SCN filled_tx_scn(SCN::min_scn());
 | 
				
			||||||
  for (int64_t i = 0; OB_SUCC(ret) && i < minor_tables.count(); ++i) {
 | 
					  for (int64_t i = 0; OB_SUCC(ret) && i < minor_tables.count(); ++i) {
 | 
				
			||||||
    ObITable *table =  minor_tables.at(i);
 | 
					    ObITable *table =  minor_tables.at(i);
 | 
				
			||||||
    if (OB_FAIL(check_minor_table_continue_(table, prev_table))) {
 | 
					    if (OB_FAIL(check_minor_table_continue_(table, prev_table, filled_tx_scn))) {
 | 
				
			||||||
      LOG_WARN("failed to check minor table continue", K(ret), KPC(table));
 | 
					      LOG_WARN("failed to check minor table continue", K(ret), KPC(table));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -2274,30 +2275,41 @@ int ObTabletTableStore::cut_ha_sstable_scn_range_(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int ObTabletTableStore::check_minor_table_continue_(
 | 
					int ObTabletTableStore::check_minor_table_continue_(
 | 
				
			||||||
    ObITable *table,
 | 
					    ObITable *table,
 | 
				
			||||||
    ObITable *prev_table) const
 | 
					    ObITable *&prev_table,
 | 
				
			||||||
 | 
					    share::SCN &filled_tx_scn) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  ObSSTable *curr_sstable = nullptr;
 | 
					  ObSSTable *curr_sstable = nullptr;
 | 
				
			||||||
  ObSSTable *prev_sstable = nullptr;
 | 
					
 | 
				
			||||||
  if (OB_UNLIKELY(OB_ISNULL(table) || !table->is_multi_version_minor_sstable())) {
 | 
					  if (OB_UNLIKELY(OB_ISNULL(table) || !table->is_multi_version_minor_sstable())) {
 | 
				
			||||||
    ret = OB_ERR_UNEXPECTED;
 | 
					    ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
    LOG_WARN("table must be multi version minor table", K(ret), KPC(table));
 | 
					    LOG_WARN("table must be multi version minor table", K(ret), KPC(table));
 | 
				
			||||||
 | 
					  } else if (FALSE_IT(curr_sstable = static_cast<ObSSTable *>(table))) {
 | 
				
			||||||
  } else if (OB_ISNULL(prev_table)) {
 | 
					  } else if (OB_ISNULL(prev_table)) {
 | 
				
			||||||
    // do nothing
 | 
					    //do nothing
 | 
				
			||||||
  } else if (table->get_start_scn() > prev_table->get_end_scn()
 | 
					  } else if (table->get_start_scn() > prev_table->get_end_scn()
 | 
				
			||||||
      || table->get_end_scn() <= prev_table->get_end_scn()) {
 | 
					      || table->get_end_scn() <= prev_table->get_end_scn()) {
 | 
				
			||||||
    ret = OB_ERR_SYS;
 | 
					    ret = OB_ERR_SYS;
 | 
				
			||||||
    LOG_ERROR("table scn range not continuous or overlap", K(ret), KPC(table), KPC(prev_table));
 | 
					    LOG_ERROR("table scn range not continuous or overlap", K(ret), KPC(table), KPC(prev_table));
 | 
				
			||||||
  } else if (FALSE_IT(curr_sstable = static_cast<ObSSTable *>(table))) {
 | 
					  } else if (table->get_key().tablet_id_.is_ls_inner_tablet()) {
 | 
				
			||||||
  } else if (FALSE_IT(prev_sstable = static_cast<ObSSTable *>(prev_table))) {
 | 
					    //do nothing
 | 
				
			||||||
  } else if (table->get_key().tablet_id_.is_ls_inner_tablet() || prev_sstable->get_filled_tx_scn().is_max()) {
 | 
					  } else if (curr_sstable->is_empty() || curr_sstable->get_filled_tx_scn().is_max()) {
 | 
				
			||||||
    // do nothing
 | 
					    //skip empty sstable pr max filled tx scn for compatible
 | 
				
			||||||
  } else if (curr_sstable->get_filled_tx_scn() < prev_sstable->get_filled_tx_scn()) {
 | 
					    LOG_INFO("current sstable is empty or filled tx scn is max, skip check this tablet filled tx scn", KPC(curr_sstable));
 | 
				
			||||||
 | 
					  } else if (curr_sstable->get_filled_tx_scn() < filled_tx_scn) {
 | 
				
			||||||
    ret = OB_ERR_SYS;
 | 
					    ret = OB_ERR_SYS;
 | 
				
			||||||
    LOG_WARN("sstable's filled_tx_scn is out of order", K(ret), KPC(table), KP(prev_table),
 | 
					    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());
 | 
					        "curr_filled_tx_scn", curr_sstable->get_filled_tx_scn(), "prev_filled_tx_scn", filled_tx_scn);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (OB_SUCC(ret)) {
 | 
				
			||||||
 | 
					    prev_table = table;
 | 
				
			||||||
 | 
					    if (!curr_sstable->get_key().tablet_id_.is_ls_inner_tablet()
 | 
				
			||||||
 | 
					        && !curr_sstable->is_empty()
 | 
				
			||||||
 | 
					        && !curr_sstable->get_filled_tx_scn().is_max()) {
 | 
				
			||||||
 | 
					      filled_tx_scn = curr_sstable->get_filled_tx_scn();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  prev_table = table;
 | 
					 | 
				
			||||||
  return ret;
 | 
					  return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2308,6 +2320,7 @@ int ObTabletTableStore::check_minor_tables_continue_(
 | 
				
			|||||||
  int ret = OB_SUCCESS;
 | 
					  int ret = OB_SUCCESS;
 | 
				
			||||||
  ObITable *prev_table = nullptr;
 | 
					  ObITable *prev_table = nullptr;
 | 
				
			||||||
  prev_table = nullptr;
 | 
					  prev_table = nullptr;
 | 
				
			||||||
 | 
					  SCN filled_tx_scn(SCN::min_scn());
 | 
				
			||||||
  if (count > 0 && OB_ISNULL(minor_sstables)) {
 | 
					  if (count > 0 && OB_ISNULL(minor_sstables)) {
 | 
				
			||||||
    ret = OB_ERR_UNEXPECTED;
 | 
					    ret = OB_ERR_UNEXPECTED;
 | 
				
			||||||
    LOG_WARN("check minor tables continue minor sstables is unexpected", K(ret), KP(minor_sstables), K(count));
 | 
					    LOG_WARN("check minor tables continue minor sstables is unexpected", K(ret), KP(minor_sstables), K(count));
 | 
				
			||||||
@ -2315,7 +2328,7 @@ int ObTabletTableStore::check_minor_tables_continue_(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  for (int64_t i = 0; OB_SUCC(ret) && i < count; ++i) {
 | 
					  for (int64_t i = 0; OB_SUCC(ret) && i < count; ++i) {
 | 
				
			||||||
    ObITable *table =  minor_sstables[i];
 | 
					    ObITable *table =  minor_sstables[i];
 | 
				
			||||||
    if (OB_FAIL(check_minor_table_continue_(table, prev_table))) {
 | 
					    if (OB_FAIL(check_minor_table_continue_(table, prev_table, filled_tx_scn))) {
 | 
				
			||||||
      LOG_WARN("failed to check minor table continue", K(ret), KPC(table));
 | 
					      LOG_WARN("failed to check minor table continue", K(ret), KPC(table));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -308,7 +308,8 @@ private:
 | 
				
			|||||||
      ObITable **minor_sstables) const;
 | 
					      ObITable **minor_sstables) const;
 | 
				
			||||||
  int check_minor_table_continue_(
 | 
					  int check_minor_table_continue_(
 | 
				
			||||||
      ObITable *table,
 | 
					      ObITable *table,
 | 
				
			||||||
      ObITable *prev_table) const;
 | 
					      ObITable *&prev_table,
 | 
				
			||||||
 | 
					      share::SCN &filled_tx_scn) const;
 | 
				
			||||||
  int combine_ha_minor_sstables_(
 | 
					  int combine_ha_minor_sstables_(
 | 
				
			||||||
      const ObTablet &tablet,
 | 
					      const ObTablet &tablet,
 | 
				
			||||||
      common::ObIArray<ObITable *> &old_store_minor_sstables,
 | 
					      common::ObIArray<ObITable *> &old_store_minor_sstables,
 | 
				
			||||||
 | 
				
			|||||||
@ -1096,6 +1096,42 @@ TEST_F(TestCompactionPolicy, test_minor_dag_intersect)
 | 
				
			|||||||
  ASSERT_EQ(false, (dag1 == dag2));
 | 
					  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<share::ObFreezeInfo> 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<ObTabletTableStore> 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
 | 
					} //unittest
 | 
				
			||||||
} //oceanbase
 | 
					} //oceanbase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user