[CP] Fix transfer handler work before standby swith to primary

This commit is contained in:
godyangfight
2024-04-02 09:40:32 +00:00
committed by ob-robot
parent a2bb75870d
commit dbb5c49037

View File

@ -397,11 +397,18 @@ int ObTransferHandler::check_self_is_leader_(bool &is_leader)
ObRole role = ObRole::INVALID_ROLE;
int64_t proposal_id = 0;
const uint64_t tenant_id = MTL_ID();
bool is_primary_tenant = true;
is_leader = false;
if (!is_inited_) {
ret = OB_NOT_INIT;
LOG_WARN("transfer handler do not init", K(ret));
} else if (OB_FAIL(ObStorageHAUtils::check_is_primary_tenant(tenant_id, is_primary_tenant))) {
//Setting the tenant as the primary tenant from the standby tenant and changing the leader attribute of palf are not atomic.
//The attributes of palf will change first, and then the attributes of the tenant will change.
LOG_WARN("failed to check is primary tenant", K(ret), K(tenant_id));
} else if (!is_primary_tenant) {
is_leader = false;
} else if (OB_FAIL(ls_->get_log_handler()->get_role(role, proposal_id))) {
LOG_WARN("failed to get role", K(ret), KPC(ls_));
} else if (is_strong_leader(role)) {