[Election] fix LeaderCoordinator and FailureDetector not exit
This commit is contained in:
@ -657,8 +657,8 @@ int MockTenantModuleEnv::init()
|
||||
MTL_BIND2(mtl_new_default, ObTenantTabletScheduler::mtl_init, nullptr, mtl_stop_default, mtl_wait_default, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, share::ObTenantDagScheduler::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, ObTenantCheckpointSlogHandler::mtl_init, nullptr, mtl_stop_default, mtl_wait_default, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObLeaderCoordinator::mtl_init, coordinator::ObLeaderCoordinator::mtl_start, coordinator::ObLeaderCoordinator::mtl_stop, coordinator::ObLeaderCoordinator::mtl_wait, coordinator::ObLeaderCoordinator::mtl_destroy);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObFailureDetector::mtl_init, coordinator::ObFailureDetector::mtl_start, coordinator::ObFailureDetector::mtl_stop, coordinator::ObFailureDetector::mtl_wait, coordinator::ObFailureDetector::mtl_destroy);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObLeaderCoordinator::mtl_init, coordinator::ObLeaderCoordinator::mtl_start, coordinator::ObLeaderCoordinator::mtl_stop, coordinator::ObLeaderCoordinator::mtl_wait, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObFailureDetector::mtl_init, coordinator::ObFailureDetector::mtl_start, coordinator::ObFailureDetector::mtl_stop, coordinator::ObFailureDetector::mtl_wait, mtl_destroy_default);
|
||||
MTL_BIND2(ObLobManager::mtl_new, mtl_init_default, mtl_start_default, mtl_stop_default, mtl_wait_default, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, share::detector::ObDeadLockDetectorMgr::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, storage::ObTenantTabletStatMgr::mtl_init, nullptr, mtl_stop_default, mtl_wait_default, mtl_destroy_default)
|
||||
|
||||
@ -52,6 +52,8 @@ ObFailureDetector::ObFailureDetector()
|
||||
COORDINATOR_LOG(INFO, "ObFailureDetector constructed");
|
||||
}
|
||||
|
||||
ObFailureDetector::~ObFailureDetector() {}
|
||||
|
||||
constexpr int VALUE_BUFFER_SIZE = 512;
|
||||
|
||||
int ObFailureDetector::mtl_init(ObFailureDetector *&p_failure_detector)
|
||||
@ -116,25 +118,14 @@ void ObFailureDetector::mtl_wait(ObFailureDetector *&p_failure_detector)
|
||||
}
|
||||
}
|
||||
|
||||
void ObFailureDetector::mtl_destroy(ObFailureDetector *&p_failure_detector)
|
||||
{
|
||||
if (OB_ISNULL(p_failure_detector)) {
|
||||
COORDINATOR_LOG_RET(WARN, OB_INVALID_ARGUMENT, "p_failure_detector is NULL");
|
||||
} else {
|
||||
COORDINATOR_LOG(INFO, "ObFailureDetector mtl destroy");
|
||||
}
|
||||
}
|
||||
|
||||
void ObFailureDetector::destroy()
|
||||
{
|
||||
LC_TIME_GUARD(1_s);
|
||||
failure_task_handle_.stop_and_wait();
|
||||
recovery_task_handle_.stop_and_wait();
|
||||
has_add_clog_hang_event_ = false;
|
||||
has_add_slog_hang_event_ = false;
|
||||
has_add_sstable_hang_event_ = false;
|
||||
has_add_clog_full_event_ = false;
|
||||
COORDINATOR_LOG(INFO, "failure detector destroyed", K(lbt()));
|
||||
COORDINATOR_LOG(INFO, "ObFailureDetector mtl destroy");
|
||||
}
|
||||
|
||||
void ObFailureDetector::detect_recover()
|
||||
@ -260,8 +251,6 @@ int ObFailureDetector::remove_failure_event(const FailureEvent &event)
|
||||
(void) insert_event_to_table_(events_with_ops_[idx].event_, events_with_ops_[idx].recover_detect_operation_, "REMOVE FAILURE");
|
||||
if (CLICK_FAIL(events_with_ops_.remove(idx))) {
|
||||
COORDINATOR_LOG(WARN, "remove event failed", KR(ret), K(event), K(events_with_ops_));
|
||||
} else if (CLICK_FAIL(events_with_ops_.remove(idx))) {
|
||||
COORDINATOR_LOG(ERROR, "remove event failed", KR(ret), K(event), K(events_with_ops_));
|
||||
} else {
|
||||
COORDINATOR_LOG(INFO, "user remove failure event success", KR(ret), K(event), K(events_with_ops_));
|
||||
}
|
||||
|
||||
@ -48,19 +48,12 @@ class ObFailureDetector
|
||||
friend class ObLeaderCoordinator;
|
||||
public:
|
||||
ObFailureDetector();
|
||||
/**
|
||||
* @description: 初始化timer,提交一detect_recover()和detect_connection_status()任务
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
* @Date: 2022-01-04 15:27:39
|
||||
*/
|
||||
int init(ObLeaderCoordinator *coordinator);
|
||||
~ObFailureDetector();
|
||||
void destroy();
|
||||
static int mtl_init(ObFailureDetector *&p_failure_detector);
|
||||
static int mtl_start(ObFailureDetector *&p_failure_detector);
|
||||
static void mtl_stop(ObFailureDetector *&p_failure_detector);
|
||||
static void mtl_wait(ObFailureDetector *&p_failure_detector);
|
||||
static void mtl_destroy(ObFailureDetector *&p_failure_detector);
|
||||
/**
|
||||
* @description: 设置一个不可自动恢复的failure,需要由注册的模块手动调用remove_failure_event()接口恢复failure,否则将持续存在
|
||||
* @param {FailureEvent} event failure事件,定义在failure_event.h中
|
||||
|
||||
@ -36,6 +36,8 @@ ObLeaderCoordinator::ObLeaderCoordinator()
|
||||
lock_(common::ObLatchIds::ELECTION_LOCK)
|
||||
{}
|
||||
|
||||
ObLeaderCoordinator::~ObLeaderCoordinator() {}
|
||||
|
||||
struct AllLsElectionReferenceInfoFactory
|
||||
{
|
||||
static ObArray<LsElectionReferenceInfo> *create_new()
|
||||
@ -58,6 +60,16 @@ struct AllLsElectionReferenceInfoFactory
|
||||
}
|
||||
};
|
||||
|
||||
void ObLeaderCoordinator::destroy()
|
||||
{
|
||||
LC_TIME_GUARD(1_s);
|
||||
recovery_detect_timer_.stop_and_wait();
|
||||
failure_detect_timer_.stop_and_wait();
|
||||
AllLsElectionReferenceInfoFactory::delete_obj(all_ls_election_reference_info_);
|
||||
all_ls_election_reference_info_ = NULL;
|
||||
COORDINATOR_LOG(INFO, "ObLeaderCoordinator mtl destroy");
|
||||
}
|
||||
|
||||
int ObLeaderCoordinator::mtl_init(ObLeaderCoordinator *&p_coordinator)// init timer
|
||||
{
|
||||
LC_TIME_GUARD(1_s);
|
||||
@ -119,20 +131,6 @@ void ObLeaderCoordinator::mtl_wait(ObLeaderCoordinator *&p_coordinator)// wait t
|
||||
}
|
||||
}
|
||||
|
||||
void ObLeaderCoordinator::mtl_destroy(ObLeaderCoordinator *&p_coordinator)// destroy timer
|
||||
{
|
||||
LC_TIME_GUARD(1_s);
|
||||
if (OB_ISNULL(p_coordinator)) {
|
||||
COORDINATOR_LOG_RET(WARN, OB_INVALID_ARGUMENT, "p_coordinator is NULL");
|
||||
} else {
|
||||
p_coordinator->recovery_detect_timer_.stop_and_wait();
|
||||
p_coordinator->failure_detect_timer_.stop_and_wait();
|
||||
AllLsElectionReferenceInfoFactory::delete_obj(p_coordinator->all_ls_election_reference_info_);
|
||||
p_coordinator->all_ls_election_reference_info_ = NULL;
|
||||
COORDINATOR_LOG(INFO, "ObLeaderCoordinator mtl destroy");
|
||||
}
|
||||
}
|
||||
|
||||
void ObLeaderCoordinator::refresh()
|
||||
{
|
||||
LC_TIME_GUARD(1_s);
|
||||
|
||||
@ -49,7 +49,8 @@ class ObLeaderCoordinator
|
||||
friend class unittest::TestElectionPriority;
|
||||
public:
|
||||
ObLeaderCoordinator();
|
||||
~ObLeaderCoordinator() { }
|
||||
~ObLeaderCoordinator();
|
||||
void destroy();
|
||||
ObLeaderCoordinator(const ObLeaderCoordinator &rhs) = delete;
|
||||
ObLeaderCoordinator& operator=(const ObLeaderCoordinator &rhs) = delete;
|
||||
static int mtl_init(ObLeaderCoordinator *&p_coordinator);
|
||||
|
||||
@ -326,8 +326,8 @@ int ObMultiTenant::init(ObAddr myaddr,
|
||||
MTL_BIND2(mtl_new_default, rootserver::ObPrimaryLSService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, rootserver::ObRecoveryLSService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, rootserver::ObRestoreService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObLeaderCoordinator::mtl_init, coordinator::ObLeaderCoordinator::mtl_start, coordinator::ObLeaderCoordinator::mtl_stop, coordinator::ObLeaderCoordinator::mtl_wait, coordinator::ObLeaderCoordinator::mtl_destroy);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObFailureDetector::mtl_init, coordinator::ObFailureDetector::mtl_start, coordinator::ObFailureDetector::mtl_stop, coordinator::ObFailureDetector::mtl_wait, coordinator::ObFailureDetector::mtl_destroy);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObLeaderCoordinator::mtl_init, coordinator::ObLeaderCoordinator::mtl_start, coordinator::ObLeaderCoordinator::mtl_stop, coordinator::ObLeaderCoordinator::mtl_wait, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, coordinator::ObFailureDetector::mtl_init, coordinator::ObFailureDetector::mtl_start, coordinator::ObFailureDetector::mtl_stop, coordinator::ObFailureDetector::mtl_wait, mtl_destroy_default);
|
||||
MTL_BIND2(ObLobManager::mtl_new, mtl_init_default, mtl_start_default, mtl_stop_default, mtl_wait_default, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, ObStorageHAService::mtl_init, mtl_start_default, mtl_stop_default, mtl_wait_default, mtl_destroy_default);
|
||||
MTL_BIND2(mtl_new_default, ObGlobalAutoIncService::mtl_init, nullptr, nullptr, nullptr, mtl_destroy_default);
|
||||
|
||||
Reference in New Issue
Block a user