fix strict defense & del useless code

This commit is contained in:
yangqise7en
2023-07-13 13:18:17 +00:00
committed by ob-robot
parent a8b35aca3d
commit a821d6da22
11 changed files with 13 additions and 99 deletions

View File

@ -535,7 +535,7 @@ void ObMediumCompactionInfo::gene_info(
char* buf, const int64_t buf_len, int64_t &pos) const
{
J_KV("compaction_type", ObMediumCompactionInfo::get_compaction_type_str((ObCompactionType)compaction_type_),
K(medium_snapshot_), K_(parallel_merge_info));
K(medium_snapshot_), K_(last_medium_snapshot), K_(parallel_merge_info));
}
int64_t ObMediumCompactionInfo::to_string(char* buf, const int64_t buf_len) const

View File

@ -225,7 +225,7 @@ public:
uint64_t contain_parallel_range_ : SCS_ONE_BIT;
uint64_t medium_merge_reason_ : 8;
uint64_t is_schema_changed_ : SCS_ONE_BIT;
uint64_t tenant_id_ : 16; // record tenant_id of ls primary_leader
uint64_t tenant_id_ : 16; // record tenant_id of ls primary_leader, just for throw medium
uint64_t reserved_ : SCS_RESERVED_BITS;
};
};

View File

@ -681,14 +681,14 @@ int ObMediumCompactionInfoList::check_medium_info_and_last_major(
if (nullptr != last_major_sstable
&& ObMediumCompactionInfo::MEIDUM_COMPAT_VERSION_V2 == medium_info.medium_compat_version_
&& medium_info.medium_snapshot_ > last_major_sstable->get_snapshot_version()) {
if (medium_info.from_cur_cluster()) {
if (medium_info.from_cur_cluster()) { // same cluster_id & same tenant_id
if (OB_UNLIKELY(medium_info.last_medium_snapshot_ != last_major_sstable->get_snapshot_version())) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("last medium snapshot in medium info is not equal to last "
"major sstable, medium info may lost",
KR(ret), K(medium_info), KPC(last_major_sstable));
}
} else { // check next freeze info in inner_table & medium_info
} else if (medium_info.is_major_compaction()) { // check next freeze info in inner_table & medium_info
const int64_t last_major_sstable_snapshot = last_major_sstable->get_snapshot_version();
ObTenantFreezeInfoMgr::FreezeInfo freeze_info;
if (OB_FAIL(MTL_CALL_FREEZE_INFO_MGR(
@ -708,6 +708,9 @@ int ObMediumCompactionInfoList::check_medium_info_and_last_major(
LOG_ERROR("next major medium info may lost",
KR(ret), "freeze_version", freeze_info.freeze_version, K(medium_info), KPC(last_major_sstable));
}
} else {
// medium info from same cluster_id, can't make sure all medium info exists, so not check medium & last_major
// like primary-standby relations: cluster1(A) -> cluster2(B) -> cluster1(C), medium info is dropped by B for different cluster_id
}
}
return ret;

View File

@ -182,7 +182,7 @@ private:
uint64_t reserved_ : MEDIUM_LIST_INFO_RESERVED_BITS;
};
};
int64_t last_medium_scn_;
int64_t last_medium_scn_; // record last finish medium_scn
MediumInfoList medium_info_list_; // need for compat, will not store any MediumCompactionInfo after 4.2
};

View File

@ -294,7 +294,7 @@ int ObMajorPartitionMergeFuser::fuse_delete_row(
if (OB_ISNULL(row_iter)) {
ret = OB_INVALID_ARGUMENT;
STORAGE_LOG(WARN, "Invalid null argument", KP(row_iter), K(ret));
} else if (!row_iter->get_curr_row()->row_flag_.is_delete()) {
} else if (OB_UNLIKELY(!row_iter->get_curr_row()->row_flag_.is_delete())) {
ret = OB_ERR_UNEXPECTED;
STORAGE_LOG(WARN, "Unexpected row flag", K(ret));
} else {
@ -315,30 +315,6 @@ int ObMajorPartitionMergeFuser::fuse_delete_row(
return ret;
}
int ObMajorPartitionMergeFuser::fuse_old_row(ObPartitionMergeIter *row_iter, blocksstable::ObDatumRow *row)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(row_iter) || OB_ISNULL(row)) {
ret = OB_INVALID_ARGUMENT;
STORAGE_LOG(WARN, "Invalid null argument", KP(row), KP(row_iter), K(ret));
} else {
bool final_result = false;
nop_pos_.reset();
if (row_iter->get_curr_row()->row_flag_.is_delete()) {
if (OB_FAIL(fuse_delete_row(row_iter, *row, schema_rowkey_column_cnt_))) {
STORAGE_LOG(WARN, "Failed to fuse delete row", K(ret));
}
} else if (OB_FAIL(storage::ObRowFuse::fuse_row(*row_iter->get_curr_row(), *row, nop_pos_, final_result))) {
STORAGE_LOG(WARN, "Failed to fuse old row", K(ret));
} else if (OB_FAIL(storage::ObRowFuse::fuse_row(default_row_, *row, nop_pos_, final_result))) {
STORAGE_LOG(WARN, "Failed to fuse default row for old row", K(ret));
}
}
return ret;
}
/*
*ObMetaPartitionMergeFuser
*/
@ -383,12 +359,9 @@ int ObMinorPartitionMergeFuser::inner_check_merge_param(const ObMergeParameter &
STORAGE_LOG(WARN, "Unexpected merge param with major fuser", K(merge_param), K(ret));
} else {
ObITable *first_table = merge_param.tables_handle_->get_table(0);
if (NULL == first_table) {
ret = OB_ERR_SYS;
LOG_ERROR("first table must not null", K(ret), K(merge_param));
} else if (!first_table->is_multi_version_table()) {
if (OB_UNLIKELY(NULL == first_table || !first_table->is_multi_version_table())) {
ret = OB_ERR_SYS;
LOG_ERROR("invalid first table type", K(ret), K(*first_table));
LOG_ERROR("invalid first table", K(ret), KPC(first_table));
}
}
return ret;

View File

@ -42,8 +42,7 @@ public:
nop_pos_(),
allocator_("MergeFuser"),
multi_version_column_ids_(common::OB_MAX_COLUMN_NUMBER, allocator_),
is_inited_(false),
purged_count_(0)
is_inited_(false)
{}
virtual ~ObIPartitionMergeFuser();
virtual int init(const ObMergeParameter &merge_param);
@ -56,7 +55,6 @@ public:
{
return multi_version_column_ids_;
}
virtual OB_INLINE int64_t get_purged_count() const { return purged_count_; }
virtual const char *get_fuser_name() const = 0;
virtual int set_multi_version_flag(const blocksstable::ObMultiVersionRowFlag &row_flag);
VIRTUAL_TO_STRING_KV(K_(schema_rowkey_column_cnt), K_(column_cnt),
@ -81,7 +79,6 @@ protected:
// for mini & minor: store multi_version rowkey column description
common::ObArray<share::schema::ObColDesc, common::ObIAllocator &> multi_version_column_ids_;
bool is_inited_;
int64_t purged_count_;
};
class ObMajorPartitionMergeFuser : public ObIPartitionMergeFuser
@ -101,8 +98,6 @@ public:
protected:
virtual int inner_check_merge_param(const ObMergeParameter &merge_param);
virtual int inner_init(const ObMergeParameter &merge_param) override;
virtual int fuse_old_row(ObPartitionMergeIter *row_iter, blocksstable::ObDatumRow *row);
virtual int fuse_delete_row(ObPartitionMergeIter *row_iter, blocksstable::ObDatumRow &row,
const int64_t rowkey_column_cnt) override;
protected:
@ -132,8 +127,7 @@ class ObMinorPartitionMergeFuser : public ObIPartitionMergeFuser
public:
ObMinorPartitionMergeFuser()
: ObIPartitionMergeFuser(),
multi_version_rowkey_column_cnt_(0),
col_id_set_()
multi_version_rowkey_column_cnt_(0)
{}
virtual ~ObMinorPartitionMergeFuser();
virtual void reset() override;
@ -150,7 +144,6 @@ protected:
const int64_t rowkey_column_cnt) = 0;
protected:
int64_t multi_version_rowkey_column_cnt_;
common::ObBitSet<> col_id_set_;
DISALLOW_COPY_AND_ASSIGN(ObMinorPartitionMergeFuser);
};

View File

@ -193,27 +193,6 @@ void ObPartitionMergeIter::revise_macro_range(ObDatumRange &range) const
range.end_key_.datum_cnt_ = MIN(schema_rowkey_column_cnt_, range.end_key_.datum_cnt_);
}
bool ObPartitionMergeIter::is_tx_table_valid() const
{
bool bret = true;
// TODO : @gengli is_tx_table_valid()
// storage::ObTxTableGuard *tx_table_guard = nullptr;
// transaction::ObPartitionTransCtxMgr *ctx_mgr = nullptr;
// if (IS_NOT_INIT) {
// LOG_WARN("ObPartitionMergeIter is not inited", K(*this));
// } else if (OB_ISNULL(tx_table_guard = store_ctx_.mem_ctx_->get_tx_table_guard())) {
// STORAGE_LOG(ERROR, "The trans state table is invalid", K(*this));
// } else if (OB_ISNULL(ctx_mgr = trans_table_guard->
// get_trans_state_table().get_partition_trans_ctx_mgr())) {
// STORAGE_LOG(ERROR, "The partition ctx mgr is invalid", K(*this));
// } else {
// bret = !ctx_mgr->is_partition_stopped();
// }
return bret;
}
int ObPartitionMergeIter::check_merge_range_cross(ObDatumRange &data_range, bool &range_cross)
{
int ret = OB_SUCCESS;

View File

@ -76,7 +76,6 @@ public:
virtual int open_curr_range(const bool for_rewrite, const bool for_compare = false) { UNUSEDx(for_rewrite, for_compare); return OB_NOT_SUPPORTED; }
virtual bool is_macro_block_opened() const { return true; }
virtual bool is_micro_block_opened() const { return true; }
virtual bool is_tx_table_valid() const;
virtual OB_INLINE const blocksstable::ObDatumRow *get_curr_row() const { return curr_row_; }
virtual int get_curr_range(blocksstable::ObDatumRange &range) const { UNUSED(range); return OB_NOT_SUPPORTED; }
//TODO return ptr instead
@ -230,12 +229,6 @@ public:
virtual OB_INLINE bool is_multi_version_minor_iter() const { return true; }
virtual bool is_curr_row_commiting() const;
virtual int collect_tnode_dml_stat(storage::ObTransNodeDMLStat &tnode_stat) const override;
virtual void reset_first_multi_version_row_flag()
{
if (nullptr != curr_row_) {
const_cast<blocksstable::ObDatumRow *>(curr_row_)->mvcc_row_flag_.set_first_multi_version_row(false);
}
}
INHERIT_TO_STRING_KV("ObPartitionMinorRowMergeIter", ObPartitionMergeIter, K_(ghost_row_count),
K_(check_committing_trans_compacted), K_(row_queue));
protected:

View File

@ -722,9 +722,6 @@ int ObPartitionMergeHelper::check_iter_end() const
} else if (!iter->is_iter_end()) {
ret = OB_ERR_SYS;
STORAGE_LOG(ERROR, "Merge iter not iter to end", K(ret), KPC(iter));
} else if (i == 0 && !iter->is_tx_table_valid()) {
ret = OB_STATE_NOT_MATCH;
STORAGE_LOG(ERROR, "Failed to complete the merge because of broken txn table", K(ret), KPC(iter));
}
}
}

View File

@ -348,25 +348,6 @@ int ObTabletMergeInfo::create_sstable(ObTabletMergeCtx &ctx)
return ret;
}
int ObTabletMergeInfo::get_data_macro_block_count(int64_t &macro_block_count)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("ObTabletMergeInfo has not been inited", K(ret));
} else {
macro_block_count = 0;
for (int64_t i = 0; OB_SUCC(ret) && i < block_ctxs_.count(); i++) {
if (OB_NOT_NULL(block_ctxs_.at(i))) {
macro_block_count += block_ctxs_.at(i)->macro_block_list_.count();
}
}
}
return ret;
}
int ObTabletMergeInfo::new_block_write_ctx(blocksstable::ObMacroBlocksWriteCtx *&ctx)
{
int ret = OB_SUCCESS;

View File

@ -60,7 +60,6 @@ public:
ObSSTableMergeInfo &get_sstable_merge_info() { return sstable_merge_info_; }
blocksstable::ObSSTableIndexBuilder *get_index_builder() const { return index_builder_; }
void destroy();
int get_data_macro_block_count(int64_t &macro_block_count);
TO_STRING_KV(K_(is_inited), K_(sstable_merge_info), KP_(index_builder));
private:
@ -153,9 +152,7 @@ struct ObTabletMergeCtx
virtual ~ObTabletMergeCtx();
void destroy();
virtual bool is_valid() const;
bool need_full_checksum() const { return is_full_merge_; }
bool need_rewrite_macro_block(const blocksstable::ObMacroBlockDesc &macro_desc) const;
int64_t get_storage_format_work_version() const { return param_.merge_version_; }
int init_parallel_merge();
int init_merge_progress(bool is_major);
int get_merge_range(int64_t parallel_idx, blocksstable::ObDatumRange &merge_range);
@ -169,8 +166,6 @@ struct ObTabletMergeCtx
int get_schema_and_gene_from_result(const ObGetMergeTablesResult &get_merge_table_result);
int get_storage_schema_to_merge(const ObTablesHandleArray &merge_tables_handle);
int try_swap_tablet_handle();
int get_medium_compaction_info_to_store();
static bool need_swap_tablet(const ObTablet &tablet, const int64_t row_count, const int64_t macro_count);
int get_basic_info_from_result(const ObGetMergeTablesResult &get_merge_table_result);
int cal_minor_merge_param();