add swap tablet for co major
This commit is contained in:
parent
c7c4b471e5
commit
d3d55f717f
@ -104,6 +104,8 @@ struct ObCOTabletMergeCtx : public ObBasicTabletMergeCtx
|
||||
int inner_loop_prepare_index_tree(
|
||||
const uint32_t start_cg_idx,
|
||||
const uint32_t end_cg_idx);
|
||||
virtual int try_swap_tablet(ObGetMergeTablesResult &get_merge_table_result) override
|
||||
{ return ObBasicTabletMergeCtx::swap_tablet(get_merge_table_result); }
|
||||
INHERIT_TO_STRING_KV("ObCOTabletMergeCtx", ObBasicTabletMergeCtx,
|
||||
K_(array_count), K_(exe_stat));
|
||||
|
||||
|
@ -992,5 +992,39 @@ int ObBasicTabletMergeCtx::get_medium_compaction_info()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBasicTabletMergeCtx::swap_tablet(ObGetMergeTablesResult &get_merge_table_result)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// check need swap tablet when compaction
|
||||
if (OB_UNLIKELY(!is_major_or_meta_merge_type(get_merge_type()))) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("other merge type not support swap tablet", KR(ret), "param", get_dag_param());
|
||||
} else if (OB_UNLIKELY(!get_tablet()->get_tablet_meta().ha_status_.is_data_status_complete())) {
|
||||
ret = OB_STATE_NOT_MATCH;
|
||||
LOG_WARN("ha status is not allowed major", KR(ret), KPC(this));
|
||||
} else {
|
||||
ObTablesHandleArray &tables_handle = get_merge_table_result.handle_;
|
||||
int64_t row_count = 0;
|
||||
int64_t macro_count = 0;
|
||||
const ObSSTable *sstable = nullptr;
|
||||
for (int64_t i = 0; i < tables_handle.get_count(); ++i) {
|
||||
sstable = static_cast<const ObSSTable*>(tables_handle.get_table(i));
|
||||
row_count += sstable->get_row_count();
|
||||
macro_count += sstable->get_data_macro_block_count();
|
||||
} // end of for
|
||||
if (need_swap_tablet(*get_tablet(), row_count, macro_count)) {
|
||||
tables_handle.reset(); // clear tables array
|
||||
if (OB_FAIL(swap_tablet())) {
|
||||
LOG_WARN("failed to get alloc tablet handle", KR(ret));
|
||||
} else if (OB_FAIL(get_merge_tables(get_merge_table_result))) {
|
||||
if (OB_NO_NEED_MERGE != ret) {
|
||||
LOG_WARN("failed to get merge tables", KR(ret), KPC(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace compaction
|
||||
} // namespace oceanbase
|
||||
|
@ -234,6 +234,7 @@ protected:
|
||||
virtual int collect_running_info() = 0;
|
||||
int swap_tablet();
|
||||
int get_medium_compaction_info(); // for major
|
||||
int swap_tablet(ObGetMergeTablesResult &get_merge_table_result); // for major
|
||||
static const int64_t LARGE_VOLUME_DATA_ROW_COUNT_THREASHOLD = 1000L * 1000L; // 100w
|
||||
static const int64_t LARGE_VOLUME_DATA_MACRO_COUNT_THREASHOLD = 300L;
|
||||
public:
|
||||
|
@ -423,40 +423,5 @@ int ObTabletMajorMergeCtx::prepare_schema()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMajorMergeCtx::try_swap_tablet(
|
||||
ObGetMergeTablesResult &get_merge_table_result)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
// check need swap tablet when compaction
|
||||
if (OB_UNLIKELY(!is_major_or_meta_merge_type(get_merge_type()))) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("other merge type not support swap tablet", KR(ret), "param", get_dag_param());
|
||||
} else if (OB_UNLIKELY(!get_tablet()->get_tablet_meta().ha_status_.is_data_status_complete())) {
|
||||
ret = OB_STATE_NOT_MATCH;
|
||||
LOG_WARN("ha status is not allowed major", KR(ret), KPC(this));
|
||||
} else {
|
||||
ObTablesHandleArray &tables_handle = get_merge_table_result.handle_;
|
||||
int64_t row_count = 0;
|
||||
int64_t macro_count = 0;
|
||||
const ObSSTable *sstable = nullptr;
|
||||
for (int64_t i = 0; i < tables_handle.get_count(); ++i) {
|
||||
sstable = static_cast<const ObSSTable*>(tables_handle.get_table(i));
|
||||
row_count += sstable->get_row_count();
|
||||
macro_count += sstable->get_data_macro_block_count();
|
||||
} // end of for
|
||||
if (need_swap_tablet(*get_tablet(), row_count, macro_count)) {
|
||||
tables_handle.reset(); // clear tables array
|
||||
if (OB_FAIL(swap_tablet())) {
|
||||
LOG_WARN("failed to get alloc tablet handle", KR(ret));
|
||||
} else if (OB_FAIL(get_merge_tables(get_merge_table_result))) {
|
||||
if (OB_NO_NEED_MERGE != ret) {
|
||||
LOG_WARN("failed to get merge tables", KR(ret), KPC(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace compaction
|
||||
} // namespace oceanbase
|
||||
|
@ -92,7 +92,8 @@ struct ObTabletMajorMergeCtx : public ObTabletMergeCtx
|
||||
DEFAULT_CONSTRUCTOR(ObTabletMajorMergeCtx, ObTabletMergeCtx);
|
||||
protected:
|
||||
virtual int prepare_schema() override;
|
||||
virtual int try_swap_tablet(ObGetMergeTablesResult &get_merge_table_result) override;
|
||||
virtual int try_swap_tablet(ObGetMergeTablesResult &get_merge_table_result) override
|
||||
{ return ObBasicTabletMergeCtx::swap_tablet(get_merge_table_result); }
|
||||
virtual int cal_merge_param() override { return static_param_.cal_major_merge_param(); }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user