diff --git a/src/storage/compaction/ob_medium_compaction_func.cpp b/src/storage/compaction/ob_medium_compaction_func.cpp index a55f97b1cc..8fd7389336 100755 --- a/src/storage/compaction/ob_medium_compaction_func.cpp +++ b/src/storage/compaction/ob_medium_compaction_func.cpp @@ -271,6 +271,8 @@ int ObMediumCompactionScheduleFunc::schedule_next_medium_for_leader( } #endif ret = schedule_next_medium_primary_cluster(major_snapshot, schedule_stat); + } else { + LOG_TRACE("not leader", K(ret), K(role), K(ls_.get_ls_id())); } return ret; } @@ -338,8 +340,8 @@ int ObMediumCompactionScheduleFunc::schedule_next_medium_primary_cluster( } else if (OB_ISNULL(medium_info_list_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("medium info list is unexpected null", K(ret), KPC(this), KPC_(medium_info_list)); - } else if (!medium_info_list_->could_schedule_next_round()) { // check medium list int mds_table - // do nothing + } else if (!medium_info_list_->could_schedule_next_round(last_major->get_snapshot_version())) { + // check medium list int mds_table } else if (OB_FAIL(get_adaptive_reason(schedule_major_snapshot, adaptive_merge_reason))) { LOG_WARN("failed to get adaptive reason", KR(ret), K(schedule_major_snapshot)); } else if (adaptive_merge_reason > ObAdaptiveMergePolicy::AdaptiveMergeReason::NONE) { diff --git a/src/storage/compaction/ob_medium_compaction_mgr.cpp b/src/storage/compaction/ob_medium_compaction_mgr.cpp index 9a0e9c5b9b..ad17306ce6 100644 --- a/src/storage/compaction/ob_medium_compaction_mgr.cpp +++ b/src/storage/compaction/ob_medium_compaction_mgr.cpp @@ -678,5 +678,17 @@ int ObMediumCompactionInfoList::get_max_sync_medium_scn(int64_t &max_sync_medium return ret; } +bool ObMediumCompactionInfoList::could_schedule_next_round(const int64_t last_major_snapshot) const +{ + bool exist = false; + DLIST_FOREACH_NORET(info, get_list()) { + if (info->medium_snapshot_ > last_major_snapshot) { + exist = true; + break; + } + } + return !need_check_finish() && !exist; +} + } //namespace compaction } // namespace oceanbase diff --git a/src/storage/compaction/ob_medium_compaction_mgr.h b/src/storage/compaction/ob_medium_compaction_mgr.h index a5bb1251c0..0187fb2aad 100644 --- a/src/storage/compaction/ob_medium_compaction_mgr.h +++ b/src/storage/compaction/ob_medium_compaction_mgr.h @@ -102,7 +102,6 @@ public: common::ObIAllocator &allocator, const ObExtraMediumInfo &extra_medium_info, const ObTabletDumpedMediumInfo *medium_info_list); - void reset(); OB_INLINE bool is_empty() const { return 0 == medium_info_list_.get_size(); } OB_INLINE int64_t size() const { return medium_info_list_.get_size(); } @@ -115,10 +114,7 @@ public: OB_INLINE int64_t get_wait_check_medium_scn() const { return extra_info_.wait_check_flag_ ? extra_info_.last_medium_scn_ : 0; } OB_INLINE bool need_check_finish() const { return get_wait_check_medium_scn() > 0; } // check status on serialized medium list - OB_INLINE bool could_schedule_next_round() const - { - return !need_check_finish() && medium_info_list_.is_empty(); - } + OB_INLINE bool could_schedule_next_round(const int64_t last_major_snapshot) const; OB_INLINE ObMediumCompactionInfo::ObCompactionType get_last_compaction_type() const { return static_cast(extra_info_.last_compaction_type_); diff --git a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp index 6fb9c80b06..d783f89f4e 100755 --- a/src/storage/compaction/ob_tenant_tablet_scheduler.cpp +++ b/src/storage/compaction/ob_tenant_tablet_scheduler.cpp @@ -1677,7 +1677,7 @@ int ObCompactionScheduleIterator::get_next_ls(ObLSHandle &ls_handle) ++ls_idx_; ls_tablet_svr_ = nullptr; tablet_ids_.reuse(); - LOG_TRACE("tablet iter end", K(ret), K(ls_idx_), K(tablet_idx_), "tablet_cnt", tablet_ids_.count()); + LOG_TRACE("tablet iter end", K(ret), K(ls_idx_), K(tablet_idx_), "tablet_cnt", tablet_ids_.count(), K_(ls_ids)); } do { if (finish_cur_batch_) { @@ -1688,10 +1688,11 @@ int ObCompactionScheduleIterator::get_next_ls(ObLSHandle &ls_handle) } else if (OB_FAIL(get_cur_ls_handle(ls_handle))) { if (OB_LS_NOT_EXIST == ret) { LOG_TRACE("ls not exist", K(ret), K(ls_idx_), K(ls_ids_[ls_idx_])); - skip_cur_ls(); } else { LOG_WARN("failed to get ls", K(ret), K(ls_idx_), K(ls_ids_[ls_idx_])); + ret = OB_LS_NOT_EXIST; } + skip_cur_ls(); } else { ls_tablet_svr_ = ls_handle.get_ls()->get_tablet_svr(); } @@ -1745,11 +1746,11 @@ int ObCompactionScheduleIterator::get_next_tablet(ObTabletHandle &tablet_handle) } else { const common::ObTabletID &tablet_id = tablet_ids_.at(tablet_idx_); if (OB_FAIL(get_tablet_handle(tablet_id, tablet_handle))) { - if (OB_TABLET_NOT_EXIST == ret) { - tablet_idx_++; - } else { + if (OB_TABLET_NOT_EXIST != ret) { LOG_WARN("fail to get tablet", K(ret), K(tablet_idx_), K(tablet_id)); + ret = OB_TABLET_NOT_EXIST; } + tablet_idx_++; } else { tablet_handle.set_wash_priority(WashTabletPriority::WTP_LOW); tablet_idx_++; diff --git a/unittest/storage/compaction/test_compaction_iter.cpp b/unittest/storage/compaction/test_compaction_iter.cpp index 8fed19a3bf..d798508c3b 100644 --- a/unittest/storage/compaction/test_compaction_iter.cpp +++ b/unittest/storage/compaction/test_compaction_iter.cpp @@ -139,14 +139,10 @@ void TestCompactionIter::test_iter( ASSERT_EQ(loop_cnt, iter_cnt / max_batch_tablet_cnt + (iter_cnt % max_batch_tablet_cnt != 0)); } else if (error_tablet_idx < 0 || error_tablet_idx >= tablet_cnt_per_ls) { // no errno - } else if (OB_TABLET_NOT_EXIST == input_errno) { + } else { // for this errno, just skip this tablet ASSERT_EQ(iter_cnt, ls_cnt * (tablet_cnt_per_ls - 1)); ASSERT_EQ(loop_cnt, iter_cnt / max_batch_tablet_cnt + (iter_cnt % max_batch_tablet_cnt != 0)); - } else { - // for this errno, just skip cur ls, reset tablet won't be scheduled - ASSERT_EQ(iter_cnt, ls_cnt * error_tablet_idx); - ASSERT_EQ(loop_cnt, iter_cnt / max_batch_tablet_cnt + (iter_cnt % max_batch_tablet_cnt != 0)); } }