diff --git a/src/storage/tx/ob_dup_table_lease.cpp b/src/storage/tx/ob_dup_table_lease.cpp index cb44a390b..659e1495c 100644 --- a/src/storage/tx/ob_dup_table_lease.cpp +++ b/src/storage/tx/ob_dup_table_lease.cpp @@ -952,9 +952,9 @@ int ObDupTableLSLeaseMgr::LeaderLeaseMgrStatFunctor::operator()( } // update cnt_ for next read cnt_++; - - DUP_TABLE_LOG(DEBUG, "insert one row in svr list", K(ret), K(tmp_stat), K(cnt_), - K(hash_pair.second.confirmed_lease_info_), K(collect_arr_)); + // for debug + DUP_TABLE_LOG(INFO, "insert one row in svr list", K(ret), K(tmp_stat), K(cnt_), + K(hash_pair.second), K(collect_arr_)); } return ret; diff --git a/src/storage/tx/ob_dup_table_tablets.cpp b/src/storage/tx/ob_dup_table_tablets.cpp index 2d5d22ea3..0a05b4bf5 100644 --- a/src/storage/tx/ob_dup_table_tablets.cpp +++ b/src/storage/tx/ob_dup_table_tablets.cpp @@ -1237,6 +1237,16 @@ int64_t ObLSDupTabletsMgr::get_readable_tablet_set_count() return cnt; } +int64_t ObLSDupTabletsMgr::get_need_confirm_tablet_set_count() +{ + int64_t cnt = 0; + + SpinRLockGuard guard(dup_tablets_lock_); + cnt = need_confirm_new_queue_.get_size(); + + return cnt; +} + int64_t ObLSDupTabletsMgr::get_all_tablet_set_count() { int64_t cnt = 0; @@ -1256,6 +1266,44 @@ int64_t ObLSDupTabletsMgr::get_all_tablet_set_count() return cnt; } +// check exist tablet or is logging +bool ObLSDupTabletsMgr::check_removing_tablet_exist() +{ + bool bool_ret = false; + SpinRLockGuard guard(dup_tablets_lock_); + + if (OB_ISNULL(removing_old_set_)) { + bool_ret = false; + } else if (removing_old_set_->size() > 0) { + bool_ret = true; + } else if (removing_old_set_->get_change_status()->is_modifiable()){ + bool_ret = true; + } else { + bool_ret = false; + } + + return bool_ret; +} + +// check exist tablet or is logging +bool ObLSDupTabletsMgr::check_changing_new_tablet_exist() +{ + bool bool_ret = false; + SpinRLockGuard guard(dup_tablets_lock_); + + if (OB_ISNULL(changing_new_set_)) { + bool_ret = false; + } else if (changing_new_set_->size() > 0) { + bool_ret = true; + } else if (changing_new_set_->get_change_status()->is_modifiable()) { + bool_ret = true; + } else { + bool_ret = false; + } + + return bool_ret; +} + int ObLSDupTabletsMgr::leader_takeover(const bool is_resume, const bool recover_all_readable_from_ckpt) { diff --git a/src/storage/tx/ob_dup_table_tablets.h b/src/storage/tx/ob_dup_table_tablets.h index 0dad65414..f99cf28b1 100644 --- a/src/storage/tx/ob_dup_table_tablets.h +++ b/src/storage/tx/ob_dup_table_tablets.h @@ -550,6 +550,9 @@ public: int64_t get_dup_tablet_count(); bool has_dup_tablet(); int64_t get_readable_tablet_set_count(); + int64_t get_need_confirm_tablet_set_count(); + bool check_removing_tablet_exist(); + bool check_changing_new_tablet_exist(); int64_t get_all_tablet_set_count(); int leader_takeover(const bool is_resume, const bool recover_all_readable_from_ckpt); diff --git a/src/storage/tx/ob_dup_table_util.cpp b/src/storage/tx/ob_dup_table_util.cpp index ee8d2766f..c81da67a4 100644 --- a/src/storage/tx/ob_dup_table_util.cpp +++ b/src/storage/tx/ob_dup_table_util.cpp @@ -657,6 +657,7 @@ int ObDupTableLSHandler::ls_loop_handle() { int ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS; + // TODO check stopped if (!is_inited() || OB_ISNULL(lease_mgr_ptr_) || OB_ISNULL(tablets_mgr_ptr_) || OB_ISNULL(ts_sync_mgr_ptr_)) { ret = OB_NOT_INIT; @@ -664,9 +665,13 @@ int ObDupTableLSHandler::ls_loop_handle() } else if (!ls_state_helper_.is_active_ls()) { ret = OB_LS_OFFLINE; DUP_TABLE_LOG(WARN, "the ls is not active", K(ret), KPC(this)); - } else if (!has_dup_tablet()) { + } else if (!check_tablet_set_exist()) { + // if tablet set not exist, + // return OB_NO_TABLET and remove ls id form map + // else do ls loop handle ret = OB_NO_TABLET; - DUP_TABLE_LOG(INFO, "no dup tablet, no need to do loop worker", K(ret), KPC(tablets_mgr_ptr_)); + DUP_TABLE_LOG(INFO, "no dup tablet, no need to do loop worker", K(ret), + KPC(tablets_mgr_ptr_)); } else { if (ls_state_helper_.is_leader()) { if (OB_ISNULL(log_operator_) || !log_operator_->is_busy()) { @@ -1104,6 +1109,37 @@ bool ObDupTableLSHandler::has_dup_tablet() return has_dup; } +// if return false, there are no tablets and tablet set need log +bool ObDupTableLSHandler::check_tablet_set_exist() +{ + bool bool_ret = false; + + if (OB_ISNULL(tablets_mgr_ptr_)) { + bool_ret = false; + } else { + int64_t readable_and_need_confirm_set_count = + tablets_mgr_ptr_->get_readable_tablet_set_count() + + tablets_mgr_ptr_->get_need_confirm_tablet_set_count(); + + // if readable and need confirm set count > 0, return true + if (readable_and_need_confirm_set_count > 0 ) { + bool_ret = true; + } else { + // if changing new and removing set exist return true + bool chaning_and_removing_tablet_exist = + tablets_mgr_ptr_->check_changing_new_tablet_exist() + || tablets_mgr_ptr_->check_removing_tablet_exist(); + if (chaning_and_removing_tablet_exist) { + bool_ret = true; + } else { + bool_ret = false; + } + } + } + + return bool_ret; +} + int ObDupTableLSHandler::get_local_ts_info(DupTableTsInfo &ts_info) { int ret = OB_SUCCESS; diff --git a/src/storage/tx/ob_dup_table_util.h b/src/storage/tx/ob_dup_table_util.h index ca9c4309b..5d99423ec 100644 --- a/src/storage/tx/ob_dup_table_util.h +++ b/src/storage/tx/ob_dup_table_util.h @@ -179,6 +179,7 @@ public: public: int64_t get_dup_tablet_count(); + bool check_tablet_set_exist(); bool has_dup_tablet(); int gc_dup_tablets(const int64_t gc_ts, const int64_t max_task_interval); int get_local_ts_info(DupTableTsInfo &ts_info);