[DeadLock] fix core-risk when 4013
This commit is contained in:
		@ -396,6 +396,29 @@ int ObDetectorUserReportInfo::set_columns_(const int64_t idx,
 | 
			
		||||
  #undef PRINT_WRAPPER
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObDetectorUserReportInfo::assign(const ObDetectorUserReportInfo &rhs)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (OB_FAIL(extra_columns_names_.assign(rhs.extra_columns_names_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to copy array", K(rhs));
 | 
			
		||||
  } else if (OB_FAIL(extra_columns_values_.assign(rhs.extra_columns_values_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to copy array", K(rhs));
 | 
			
		||||
  } else if (OB_FAIL(extra_columns_names_guard_.assign(rhs.extra_columns_names_guard_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to copy array", K(rhs));
 | 
			
		||||
  } else if (OB_FAIL(extra_columns_values_guard_.assign(rhs.extra_columns_values_guard_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to copy array", K(rhs));
 | 
			
		||||
  } else {
 | 
			
		||||
    module_name_ = rhs.module_name_;
 | 
			
		||||
    resource_visitor_ = rhs.required_resource_;
 | 
			
		||||
    required_resource_ = rhs.required_resource_;
 | 
			
		||||
    valid_extra_column_size_ = rhs.valid_extra_column_size_;
 | 
			
		||||
    module_name_guard_ = rhs.module_name_guard_;
 | 
			
		||||
    resource_visitor_guard_ = rhs.resource_visitor_guard_;
 | 
			
		||||
    required_resource_guard_ = rhs.required_resource_guard_;
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ObDetectorInnerReportInfo::ObDetectorInnerReportInfo() :
 | 
			
		||||
  tenant_id_(INVALID_VALUE),
 | 
			
		||||
  detector_id_(INVALID_VALUE),
 | 
			
		||||
@ -417,20 +440,21 @@ int ObDetectorInnerReportInfo::set_args(const UserBinaryKey &binary_key,
 | 
			
		||||
                                        const ObDetectorUserReportInfo &user_report_info)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
 | 
			
		||||
  binary_key_ = binary_key;
 | 
			
		||||
  tenant_id_ = MTL_ID();
 | 
			
		||||
  addr_ = addr;
 | 
			
		||||
  detector_id_ = detector_id;
 | 
			
		||||
  report_time_ = report_time;
 | 
			
		||||
  created_time_ = created_time;
 | 
			
		||||
  event_id_ = event_id;
 | 
			
		||||
  if (OB_FAIL(check_and_assign_ptr_(role, 0, "ObDetectorInnerReportInfo::set_args", &role_))) {
 | 
			
		||||
    DETECT_LOG(ERROR, "assign event field failed");
 | 
			
		||||
  } else if (OB_FAIL(user_report_info_.assign(user_report_info))) {
 | 
			
		||||
    DETECT_LOG(WARN, "assign user_report_info field failed");
 | 
			
		||||
  } else {
 | 
			
		||||
    start_delay_ = start_delay;
 | 
			
		||||
    priority_ = priority;
 | 
			
		||||
    binary_key_ = binary_key;
 | 
			
		||||
    tenant_id_ = MTL_ID();
 | 
			
		||||
    addr_ = addr;
 | 
			
		||||
    detector_id_ = detector_id;
 | 
			
		||||
    report_time_ = report_time;
 | 
			
		||||
    created_time_ = created_time;
 | 
			
		||||
    event_id_ = event_id;
 | 
			
		||||
  }
 | 
			
		||||
  start_delay_ = start_delay;
 | 
			
		||||
  priority_ = priority;
 | 
			
		||||
  user_report_info_ = user_report_info;
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
@ -504,6 +528,26 @@ const ObDetectorUserReportInfo &ObDetectorInnerReportInfo::get_user_report_info(
 | 
			
		||||
  return user_report_info_;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObDetectorInnerReportInfo::assign(const ObDetectorInnerReportInfo &rhs)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (OB_FAIL(user_report_info_.assign(rhs.user_report_info_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to assign user report info", K(rhs));
 | 
			
		||||
  } else {
 | 
			
		||||
    binary_key_ = rhs.binary_key_;
 | 
			
		||||
    tenant_id_ = rhs.tenant_id_;
 | 
			
		||||
    addr_ = rhs.addr_;
 | 
			
		||||
    detector_id_ = rhs.detector_id_;
 | 
			
		||||
    report_time_ = rhs.report_time_;
 | 
			
		||||
    created_time_ = rhs.created_time_;
 | 
			
		||||
    event_id_ = rhs.event_id_;
 | 
			
		||||
    role_ = rhs.role_;
 | 
			
		||||
    start_delay_ = rhs.start_delay_;
 | 
			
		||||
    priority_ = rhs.priority_;
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}// namespace detector
 | 
			
		||||
}// namespace share
 | 
			
		||||
}// namespace oceanbase
 | 
			
		||||
 | 
			
		||||
@ -108,6 +108,8 @@ class ObDetectorUserReportInfo
 | 
			
		||||
  OB_UNIS_VERSION(1);
 | 
			
		||||
public:
 | 
			
		||||
  ObDetectorUserReportInfo();
 | 
			
		||||
  ObDetectorUserReportInfo &operator=(const ObDetectorUserReportInfo &) = delete;
 | 
			
		||||
  int assign(const ObDetectorUserReportInfo &rhs);
 | 
			
		||||
  bool is_valid() const;
 | 
			
		||||
  int set_module_name(const common::ObSharedGuard<char> &module_name);
 | 
			
		||||
  int set_visitor(const common::ObSharedGuard<char> &visitor);
 | 
			
		||||
@ -174,6 +176,8 @@ class ObDetectorInnerReportInfo
 | 
			
		||||
  OB_UNIS_VERSION(1);
 | 
			
		||||
public:
 | 
			
		||||
  ObDetectorInnerReportInfo();
 | 
			
		||||
  ObDetectorInnerReportInfo &operator=(const ObDetectorInnerReportInfo &) = delete;
 | 
			
		||||
  int assign(const ObDetectorInnerReportInfo &rhs);
 | 
			
		||||
  int set_args(const UserBinaryKey &binary_key,
 | 
			
		||||
               const common::ObAddr &addr, const uint64_t detector_id,
 | 
			
		||||
               const int64_t report_time, const int64_t created_time,
 | 
			
		||||
 | 
			
		||||
@ -49,6 +49,17 @@ bool ObDeadLockCollectInfoMessage::is_valid() const
 | 
			
		||||
  return dest_key_.is_valid();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObDeadLockCollectInfoMessage::assign(const ObDeadLockCollectInfoMessage &rhs)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  if (OB_FAIL(collected_info_.assign(rhs.collected_info_))) {
 | 
			
		||||
    DETECT_LOG(WARN, "fail to copy collected info");
 | 
			
		||||
  } else {
 | 
			
		||||
    dest_key_ = rhs.dest_key_;
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const UserBinaryKey &ObDeadLockCollectInfoMessage::get_dest_key() const
 | 
			
		||||
{
 | 
			
		||||
  return dest_key_;
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,8 @@ class ObDeadLockCollectInfoMessage
 | 
			
		||||
public:
 | 
			
		||||
  ObDeadLockCollectInfoMessage() = default;
 | 
			
		||||
  ~ObDeadLockCollectInfoMessage() = default;
 | 
			
		||||
  ObDeadLockCollectInfoMessage &operator=(const ObDeadLockCollectInfoMessage &) = delete;
 | 
			
		||||
  int assign(const ObDeadLockCollectInfoMessage &rhs);
 | 
			
		||||
  int set_dest_key(const UserBinaryKey &dest_key);
 | 
			
		||||
  int set_args(const UserBinaryKey &dest_key,
 | 
			
		||||
               const common::ObSArray<ObDetectorInnerReportInfo> &collected_info);
 | 
			
		||||
 | 
			
		||||
@ -613,30 +613,33 @@ int ObLCLNode::process_collect_info_message(const ObDeadLockCollectInfoMessage &
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  uint64_t event_id = 0;
 | 
			
		||||
 | 
			
		||||
  ObDeadLockCollectInfoMessage msg_copy = msg;
 | 
			
		||||
  const ObSArray<ObDetectorInnerReportInfo> &collected_info = msg_copy.get_collected_info();
 | 
			
		||||
  
 | 
			
		||||
  if (!collected_info.empty()) {
 | 
			
		||||
    int64_t detector_id = private_label_.get_id();
 | 
			
		||||
    const UserBinaryKey &victim = collected_info[0].get_user_key(); 
 | 
			
		||||
    DETECT_LOG_(INFO, "witness deadlock", KP(this), K(detector_id), K_(self_key), K(victim));
 | 
			
		||||
  }
 | 
			
		||||
  DETECT_TIME_GUARD(100_ms);
 | 
			
		||||
  DETECT_LOG_(INFO, "reveive collect info message", K(collected_info.count()), PRINT_WRAPPER);
 | 
			
		||||
  if (CLICK() && OB_SUCC(check_and_process_completely_collected_msg_with_lock_(collected_info))) {
 | 
			
		||||
    DETECT_LOG_(INFO, "collect info done", PRINT_WRAPPER);
 | 
			
		||||
    CLICK();
 | 
			
		||||
    (void) ObDeadLockInnerTableService::insert_all(collected_info);
 | 
			
		||||
  } else if (CLICK() && check_dead_loop_with_lock_(collected_info)) {
 | 
			
		||||
    DETECT_LOG_(INFO, "message dead loop, just drop this message", PRINT_WRAPPER);
 | 
			
		||||
  } else if (CLICK() && OB_FAIL(generate_event_id_with_lock_(collected_info, event_id))) {
 | 
			
		||||
    DETECT_LOG_(WARN, "generate event id failed", PRINT_WRAPPER);
 | 
			
		||||
  } else if (CLICK() && OB_FAIL(append_report_info_to_msg_(msg_copy, event_id))) {
 | 
			
		||||
    DETECT_LOG_(WARN, "append report info to collect info message failed", PRINT_WRAPPER);
 | 
			
		||||
  } else if (CLICK() && OB_FAIL(broadcast_with_lock_(msg_copy))) {
 | 
			
		||||
    DETECT_LOG_(WARN, "keep boardcasting collect info msg failed", PRINT_WRAPPER);
 | 
			
		||||
  ObDeadLockCollectInfoMessage msg_copy;
 | 
			
		||||
  if (OB_FAIL(msg_copy.assign(msg))) {
 | 
			
		||||
    DETECT_LOG_(WARN, "fail to copy message", PRINT_WRAPPER);
 | 
			
		||||
  } else {
 | 
			
		||||
    DETECT_LOG_(INFO, "successfully keep broadcasting collect info msg", PRINT_WRAPPER);
 | 
			
		||||
    const ObSArray<ObDetectorInnerReportInfo> &collected_info = msg_copy.get_collected_info();
 | 
			
		||||
    if (!collected_info.empty()) {
 | 
			
		||||
      int64_t detector_id = private_label_.get_id();
 | 
			
		||||
      const UserBinaryKey &victim = collected_info[0].get_user_key();
 | 
			
		||||
      DETECT_LOG_(INFO, "witness deadlock", KP(this), K(detector_id), K_(self_key), K(victim));
 | 
			
		||||
    }
 | 
			
		||||
    DETECT_TIME_GUARD(100_ms);
 | 
			
		||||
    DETECT_LOG_(INFO, "reveive collect info message", K(collected_info.count()), PRINT_WRAPPER);
 | 
			
		||||
    if (CLICK() && OB_SUCC(check_and_process_completely_collected_msg_with_lock_(collected_info))) {
 | 
			
		||||
      DETECT_LOG_(INFO, "collect info done", PRINT_WRAPPER);
 | 
			
		||||
      CLICK();
 | 
			
		||||
      (void) ObDeadLockInnerTableService::insert_all(collected_info);
 | 
			
		||||
    } else if (CLICK() && check_dead_loop_with_lock_(collected_info)) {
 | 
			
		||||
      DETECT_LOG_(INFO, "message dead loop, just drop this message", PRINT_WRAPPER);
 | 
			
		||||
    } else if (CLICK() && OB_FAIL(generate_event_id_with_lock_(collected_info, event_id))) {
 | 
			
		||||
      DETECT_LOG_(WARN, "generate event id failed", PRINT_WRAPPER);
 | 
			
		||||
    } else if (CLICK() && OB_FAIL(append_report_info_to_msg_(msg_copy, event_id))) {
 | 
			
		||||
      DETECT_LOG_(WARN, "append report info to collect info message failed", PRINT_WRAPPER);
 | 
			
		||||
    } else if (CLICK() && OB_FAIL(broadcast_with_lock_(msg_copy))) {
 | 
			
		||||
      DETECT_LOG_(WARN, "keep boardcasting collect info msg failed", PRINT_WRAPPER);
 | 
			
		||||
    } else {
 | 
			
		||||
      DETECT_LOG_(INFO, "successfully keep broadcasting collect info msg", PRINT_WRAPPER);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,7 @@ public:
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 真实使用过程中注册和搭建依赖关系的时间点是随机的,通过随机休眠模拟使用场景
 | 
			
		||||
auto collect_callback = [](ObDetectorUserReportInfo& arg){ arg = user_report_info; return OB_SUCCESS; };
 | 
			
		||||
auto collect_callback = [](ObDetectorUserReportInfo& arg){ return arg.assign(user_report_info); };
 | 
			
		||||
 | 
			
		||||
#define JUDGE_RECORDER(v1,v2,v3,v4,v5,v6,v7,v8)\
 | 
			
		||||
ASSERT_EQ(recorder.function_default_construct_time, v1);\
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user