ObChangeLSAccessModeRes新增序列化占位

This commit is contained in:
linqiucen
2023-11-07 04:39:54 +00:00
committed by ob-robot
parent c9a0c250a6
commit ab7decced9
3 changed files with 27 additions and 12 deletions

View File

@ -1637,6 +1637,9 @@ int ObRpcChangeLSAccessModeP::process()
uint64_t tenant_id = arg_.get_tenant_id(); uint64_t tenant_id = arg_.get_tenant_id();
MAKE_TENANT_SWITCH_SCOPE_GUARD(guard); MAKE_TENANT_SWITCH_SCOPE_GUARD(guard);
ObLSService *ls_svr = nullptr; ObLSService *ls_svr = nullptr;
int64_t wait_sync_scn_cost = 0;
int64_t change_access_mode_cost = 0;
int64_t begin_time = ObTimeUtility::current_time();
if (tenant_id != MTL_ID()) { if (tenant_id != MTL_ID()) {
ret = guard.switch_to(tenant_id); ret = guard.switch_to(tenant_id);
} }
@ -1668,7 +1671,9 @@ int ObRpcChangeLSAccessModeP::process()
*ls))) { *ls))) {
LOG_WARN("fail to wait user ls sync scn locally", KR(ret), K(ls_id), K(arg_.get_sys_ls_end_scn())); LOG_WARN("fail to wait user ls sync scn locally", KR(ret), K(ls_id), K(arg_.get_sys_ls_end_scn()));
} }
wait_sync_scn_cost = ObTimeUtility::current_time() - begin_time;
} }
begin_time = ObTimeUtility::current_time();
const int64_t timeout = THIS_WORKER.get_timeout_remain(); const int64_t timeout = THIS_WORKER.get_timeout_remain();
if (FAILEDx(log_handler->change_access_mode( if (FAILEDx(log_handler->change_access_mode(
arg_.get_mode_version(), arg_.get_mode_version(),
@ -1676,10 +1681,11 @@ int ObRpcChangeLSAccessModeP::process()
arg_.get_ref_scn()))) { arg_.get_ref_scn()))) {
LOG_WARN("failed to change access mode", KR(ret), K(arg_), K(timeout)); LOG_WARN("failed to change access mode", KR(ret), K(arg_), K(timeout));
} }
change_access_mode_cost = ObTimeUtility::current_time() - begin_time;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
if (OB_SUCCESS != (tmp_ret = result_.init(tenant_id, ls_id, ret))) { if (OB_SUCCESS != (tmp_ret = result_.init(tenant_id, ls_id, ret, wait_sync_scn_cost, change_access_mode_cost))) {
ret = OB_SUCC(ret) ? tmp_ret : ret; ret = OB_SUCC(ret) ? tmp_ret : ret;
LOG_WARN("failed to init res", KR(ret), K(tenant_id), K(ls_id), KR(tmp_ret)); LOG_WARN("failed to init res", KR(ret), K(tenant_id), K(ls_id), KR(tmp_ret), K(wait_sync_scn_cost), K(change_access_mode_cost));
} else { } else {
//if ret not OB_SUCCESS, res can not return //if ret not OB_SUCCESS, res can not return
ret = OB_SUCCESS; ret = OB_SUCCESS;

View File

@ -7677,22 +7677,25 @@ OB_SERIALIZE_MEMBER(ObLSAccessModeInfo, tenant_id_, ls_id_, mode_version_, acces
bool ObChangeLSAccessModeRes::is_valid() const bool ObChangeLSAccessModeRes::is_valid() const
{ {
return OB_INVALID_TENANT_ID != tenant_id_ return OB_INVALID_TENANT_ID != tenant_id_ && ls_id_.is_valid() && wait_sync_scn_cost_ >= 0 && change_access_mode_cost_ >= 0;
&& ls_id_.is_valid();
} }
int ObChangeLSAccessModeRes::init( int ObChangeLSAccessModeRes::init(
uint64_t tenant_id, const ObLSID &ls_id, uint64_t tenant_id, const ObLSID &ls_id,
int result) const int result, const int64_t wait_sync_scn_cost, const int64_t change_access_mode_cost)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id if (OB_UNLIKELY(OB_INVALID_TENANT_ID == tenant_id
|| !ls_id.is_valid())) { || !ls_id.is_valid()
|| wait_sync_scn_cost < 0
|| change_access_mode_cost < 0)) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(ls_id)); LOG_WARN("invalid argument", KR(ret), K(tenant_id), K(ls_id), K(wait_sync_scn_cost), K(change_access_mode_cost));
} else { } else {
tenant_id_ = tenant_id; tenant_id_ = tenant_id;
ls_id_ = ls_id; ls_id_ = ls_id;
ret_ = result; ret_ = result;
wait_sync_scn_cost_ = wait_sync_scn_cost;
change_access_mode_cost_ = change_access_mode_cost;
} }
return ret; return ret;
} }
@ -7703,12 +7706,14 @@ int ObChangeLSAccessModeRes::assign(const ObChangeLSAccessModeRes &other)
if (this != &other) { if (this != &other) {
tenant_id_ = other.tenant_id_; tenant_id_ = other.tenant_id_;
ls_id_ = other.ls_id_; ls_id_ = other.ls_id_;
ret = other.ret_; ret_ = other.ret_;
wait_sync_scn_cost_ = other.wait_sync_scn_cost_;
change_access_mode_cost_ = other.change_access_mode_cost_;
} }
return ret; return ret;
} }
OB_SERIALIZE_MEMBER(ObChangeLSAccessModeRes, tenant_id_, ls_id_, ret_); OB_SERIALIZE_MEMBER(ObChangeLSAccessModeRes, tenant_id_, ls_id_, ret_, wait_sync_scn_cost_, change_access_mode_cost_);
int ObNotifySwitchLeaderArg::init(const uint64_t tenant_id, const share::ObLSID &ls_id, int ObNotifySwitchLeaderArg::init(const uint64_t tenant_id, const share::ObLSID &ls_id,
const common::ObAddr &leader, const SwitchLeaderComment &comment) const common::ObAddr &leader, const SwitchLeaderComment &comment)

View File

@ -3311,12 +3311,12 @@ struct ObChangeLSAccessModeRes
OB_UNIS_VERSION(1); OB_UNIS_VERSION(1);
public: public:
ObChangeLSAccessModeRes(): tenant_id_(OB_INVALID_TENANT_ID), ObChangeLSAccessModeRes(): tenant_id_(OB_INVALID_TENANT_ID),
ls_id_(), ret_(common::OB_SUCCESS) {} ls_id_(), ret_(common::OB_SUCCESS), wait_sync_scn_cost_(0), change_access_mode_cost_(0) {}
~ObChangeLSAccessModeRes() {} ~ObChangeLSAccessModeRes() {}
bool is_valid() const; bool is_valid() const;
int init(uint64_t tenant_id, const share::ObLSID& ls_id, int ret); int init(uint64_t tenant_id, const share::ObLSID& ls_id, const int result, const int64_t wait_sync_scn_cost, const int64_t change_access_mode_cost);
int assign(const ObChangeLSAccessModeRes &other); int assign(const ObChangeLSAccessModeRes &other);
TO_STRING_KV(K_(tenant_id), K_(ls_id), K_(ret)); TO_STRING_KV(K_(tenant_id), "ls_id", ls_id_.id(), K_(ret), K_(wait_sync_scn_cost), K_(change_access_mode_cost));
int get_result() const int get_result() const
{ {
return ret_; return ret_;
@ -3329,12 +3329,16 @@ public:
{ {
return ls_id_; return ls_id_;
} }
int64_t get_wait_sync_scn_cost() const { return wait_sync_scn_cost_; }
int64_t get_change_access_mode_cost() const { return change_access_mode_cost_; }
private: private:
DISALLOW_COPY_AND_ASSIGN(ObChangeLSAccessModeRes); DISALLOW_COPY_AND_ASSIGN(ObChangeLSAccessModeRes);
private: private:
uint64_t tenant_id_; uint64_t tenant_id_;
share::ObLSID ls_id_; share::ObLSID ls_id_;
int ret_; int ret_;
int64_t wait_sync_scn_cost_;
int64_t change_access_mode_cost_;
}; };
struct ObNotifySwitchLeaderArg struct ObNotifySwitchLeaderArg