[CP] fix: get_dbms_sched_job_info maybe cause a lot of time
This commit is contained in:
parent
29c639ea68
commit
7c87556fc0
@ -268,7 +268,7 @@ int ObDBMSSchedJobExecutor::run_dbms_sched_job(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDBMSSchedJobExecutor::run_dbms_sched_job(uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id)
|
||||
int ObDBMSSchedJobExecutor::run_dbms_sched_job(uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const ObString &job_name)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDBMSSchedJobInfo job_info;
|
||||
@ -276,7 +276,7 @@ int ObDBMSSchedJobExecutor::run_dbms_sched_job(uint64_t tenant_id, bool is_oracl
|
||||
|
||||
THIS_WORKER.set_timeout_ts(INT64_MAX);
|
||||
|
||||
OZ (table_operator_.get_dbms_sched_job_info(tenant_id, is_oracle_tenant, job_id, allocator, job_info));
|
||||
OZ (table_operator_.get_dbms_sched_job_info(tenant_id, is_oracle_tenant, job_id, job_name, allocator, job_info));
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
OZ (table_operator_.update_for_start(tenant_id, job_info));
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
virtual ~ObDBMSSchedJobExecutor() {}
|
||||
int init(
|
||||
common::ObMySQLProxy *sql_proxy, share::schema::ObMultiVersionSchemaService *schema_service);
|
||||
int run_dbms_sched_job(uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id);
|
||||
int run_dbms_sched_job(uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const ObString &job_name);
|
||||
|
||||
private:
|
||||
static int init_session(
|
||||
|
@ -381,7 +381,7 @@ int ObDBMSSchedJobMaster::scheduler_job(ObDBMSSchedJobKey *job_key)
|
||||
} else {
|
||||
ObArenaAllocator allocator;
|
||||
OZ (table_operator_.get_dbms_sched_job_info(
|
||||
job_key->get_tenant_id(), job_key->is_oracle_tenant(), job_key->get_job_id(), allocator, job_info));
|
||||
job_key->get_tenant_id(), job_key->is_oracle_tenant(), job_key->get_job_id(), job_key->get_job_name(), allocator, job_info));
|
||||
|
||||
if (OB_FAIL(ret) || !job_info.valid()) {
|
||||
int tmp = alive_jobs_.erase_refactored(job_key->get_job_id_with_tenant());
|
||||
@ -401,7 +401,7 @@ int ObDBMSSchedJobMaster::scheduler_job(ObDBMSSchedJobKey *job_key)
|
||||
OZ (table_operator_.update_for_start(
|
||||
job_info.get_tenant_id(), job_info));
|
||||
OZ (job_rpc_proxy_->run_dbms_sched_job(
|
||||
job_key->get_tenant_id(), job_key->is_oracle_tenant(), job_key->get_job_id(), execute_addr, self_addr_));
|
||||
job_key->get_tenant_id(), job_key->is_oracle_tenant(), job_key->get_job_id(), job_key->get_job_name(), execute_addr, self_addr_));
|
||||
} else {
|
||||
LOG_INFO("avoid duplicate job", K(ret), K(job_info), K(can_running));
|
||||
}
|
||||
@ -434,7 +434,7 @@ int ObDBMSSchedJobMaster::destroy()
|
||||
|
||||
int ObDBMSSchedJobMaster::alloc_job_key(
|
||||
ObDBMSSchedJobKey *&job_key,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const ObString &job_name,
|
||||
uint64_t execute_at, uint64_t delay,
|
||||
bool check_job)
|
||||
{
|
||||
@ -446,7 +446,7 @@ int ObDBMSSchedJobMaster::alloc_job_key(
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to alloc memory", K(ret), K(ptr));
|
||||
} else if (OB_ISNULL(job_key =
|
||||
new(ptr)ObDBMSSchedJobKey(tenant_id, is_oracle_tenant, job_id,
|
||||
new(ptr)ObDBMSSchedJobKey(tenant_id, is_oracle_tenant, job_id, job_name,
|
||||
execute_at, delay,
|
||||
check_job))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -657,6 +657,7 @@ int ObDBMSSchedJobMaster::register_job(
|
||||
job_info.get_tenant_id(),
|
||||
job_info.is_oracle_tenant(),
|
||||
job_info.get_job_id(),
|
||||
job_info.get_job_name(),
|
||||
execute_at,
|
||||
delay,
|
||||
check_job));
|
||||
@ -665,6 +666,7 @@ int ObDBMSSchedJobMaster::register_job(
|
||||
} else {
|
||||
CK (job_key->get_tenant_id() == job_info.get_tenant_id());
|
||||
CK (job_key->get_job_id() == job_info.get_job_id());
|
||||
CK (job_key->get_job_name() == job_info.get_job_name());
|
||||
OX (job_key->set_execute_at(execute_at));
|
||||
OX (job_key->set_delay(delay));
|
||||
OX (job_key->set_check_job(check_job));
|
||||
|
@ -51,21 +51,27 @@ class ObDBMSSchedJobKey : public common::ObLink
|
||||
{
|
||||
public:
|
||||
ObDBMSSchedJobKey(
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const common::ObString &job_name,
|
||||
uint64_t execute_at, uint64_t delay,
|
||||
bool check_job)
|
||||
: tenant_id_(tenant_id),
|
||||
is_oracle_tenant_(is_oracle_tenant),
|
||||
job_id_(job_id),
|
||||
job_name_(),
|
||||
execute_at_(execute_at),
|
||||
delay_(delay),
|
||||
check_job_(check_job) {}
|
||||
check_job_(check_job) {
|
||||
job_name_.assign_buffer(job_name_buf_, JOB_NAME_MAX_SIZE);
|
||||
job_name_.write(job_name.ptr(), job_name.length());
|
||||
}
|
||||
|
||||
virtual ~ObDBMSSchedJobKey() {}
|
||||
|
||||
static constexpr int64_t JOB_NAME_MAX_SIZE = 128;
|
||||
OB_INLINE uint64_t get_job_id_with_tenant() const { return common::combine_two_ids(tenant_id_, job_id_); }
|
||||
OB_INLINE uint64_t get_tenant_id() const { return tenant_id_; }
|
||||
OB_INLINE uint64_t get_job_id() const { return job_id_; }
|
||||
OB_INLINE common::ObString &get_job_name() { return job_name_; }
|
||||
OB_INLINE uint64_t get_execute_at() const { return execute_at_;}
|
||||
OB_INLINE uint64_t get_delay() const { return delay_; }
|
||||
|
||||
@ -96,6 +102,7 @@ public:
|
||||
K_(tenant_id),
|
||||
K_(is_oracle_tenant),
|
||||
K_(job_id),
|
||||
K_(job_name),
|
||||
K_(execute_at),
|
||||
K_(delay),
|
||||
K_(check_job));
|
||||
@ -104,6 +111,8 @@ private:
|
||||
uint64_t tenant_id_;
|
||||
bool is_oracle_tenant_;
|
||||
uint64_t job_id_;
|
||||
char job_name_buf_[JOB_NAME_MAX_SIZE];
|
||||
common::ObString job_name_;
|
||||
uint64_t execute_at_;
|
||||
uint64_t delay_;
|
||||
|
||||
@ -186,7 +195,7 @@ public:
|
||||
|
||||
int alloc_job_key(
|
||||
ObDBMSSchedJobKey *&job_key,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const common::ObString &job_name,
|
||||
uint64_t execute_at, uint64_t delay,
|
||||
bool check_job = false);
|
||||
|
||||
|
@ -67,7 +67,7 @@ int ObRpcRunDBMSSchedJobP::process()
|
||||
K(ret), K(gctx_.sql_proxy_), K(gctx_.schema_service_));
|
||||
} else if (OB_FAIL(executor.init(gctx_.sql_proxy_, gctx_.schema_service_))) {
|
||||
LOG_WARN("fail to init dbms sched job executor", K(ret));
|
||||
} else if (OB_FAIL(executor.run_dbms_sched_job(arg.tenant_id_, arg.is_oracle_tenant_, arg.job_id_))) {
|
||||
} else if (OB_FAIL(executor.run_dbms_sched_job(arg.tenant_id_, arg.is_oracle_tenant_, arg.job_id_, arg.job_name_))) {
|
||||
LOG_WARN("fail to executor dbms sched job", K(ret), K(arg));
|
||||
}
|
||||
LOG_INFO("dbms sched job run rpc process end", K(ret), K(arg_));
|
||||
|
@ -28,14 +28,14 @@ namespace oceanbase
|
||||
namespace obrpc
|
||||
{
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObDBMSSchedJobArg, tenant_id_, job_id_, server_addr_, master_addr_, is_oracle_tenant_);
|
||||
OB_SERIALIZE_MEMBER(ObDBMSSchedJobArg, tenant_id_, job_id_, server_addr_, master_addr_, is_oracle_tenant_, job_name_);
|
||||
OB_SERIALIZE_MEMBER(ObDBMSSchedJobResult, tenant_id_, job_id_, server_addr_, status_code_);
|
||||
|
||||
int ObDBMSSchedJobRpcProxy::run_dbms_sched_job(
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, ObAddr server_addr, ObAddr master_addr)
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, ObString &job_name, ObAddr server_addr, ObAddr master_addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDBMSSchedJobArg arg(tenant_id, job_id, server_addr, master_addr, is_oracle_tenant);
|
||||
ObDBMSSchedJobArg arg(tenant_id, job_id, server_addr, master_addr, is_oracle_tenant, job_name);
|
||||
ObRpcAPDBMSSchedJobCB cb;
|
||||
CK (arg.is_valid());
|
||||
OZ (this->to(arg.server_addr_).by(arg.tenant_id_).run_dbms_sched_job(arg, &cb), arg);
|
||||
|
@ -33,27 +33,30 @@ class ObDBMSSchedJobArg
|
||||
public:
|
||||
ObDBMSSchedJobArg():
|
||||
tenant_id_(OB_INVALID_ID), job_id_(OB_INVALID_ID), server_addr_(), master_addr_(),
|
||||
is_oracle_tenant_(true) {}
|
||||
is_oracle_tenant_(true), job_name_() {}
|
||||
|
||||
ObDBMSSchedJobArg(uint64_t tenant_id,
|
||||
uint64_t job_id,
|
||||
common::ObAddr &server_addr,
|
||||
common::ObAddr &master_addr,
|
||||
bool is_oracle_tenant)
|
||||
bool is_oracle_tenant,
|
||||
common::ObString &job_name)
|
||||
: tenant_id_(tenant_id), job_id_(job_id), server_addr_(server_addr), master_addr_(master_addr),
|
||||
is_oracle_tenant_(is_oracle_tenant)
|
||||
is_oracle_tenant_(is_oracle_tenant), job_name_(job_name)
|
||||
{}
|
||||
|
||||
inline bool is_valid() const
|
||||
{
|
||||
return common::is_valid_tenant_id(tenant_id_)
|
||||
&& job_id_ != common::OB_INVALID_ID
|
||||
&& !job_name_.empty()
|
||||
&& server_addr_.is_valid()
|
||||
&& master_addr_.is_valid();
|
||||
}
|
||||
|
||||
TO_STRING_KV(K_(tenant_id),
|
||||
K_(job_id),
|
||||
K_(job_name),
|
||||
K_(server_addr),
|
||||
K_(master_addr),
|
||||
K_(is_oracle_tenant));
|
||||
@ -63,6 +66,7 @@ public:
|
||||
common::ObAddr server_addr_;
|
||||
common::ObAddr master_addr_;
|
||||
bool is_oracle_tenant_;
|
||||
common::ObString job_name_;
|
||||
};
|
||||
|
||||
class ObDBMSSchedJobResult
|
||||
@ -137,7 +141,7 @@ public:
|
||||
|
||||
public:
|
||||
int run_dbms_sched_job(
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, common::ObString &job_name,
|
||||
common::ObAddr server_addr, common::ObAddr master_addr);
|
||||
};
|
||||
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
|
||||
TO_STRING_KV(K(tenant_id_),
|
||||
K(job_),
|
||||
K(job_name_),
|
||||
K(lowner_),
|
||||
K(powner_),
|
||||
K(cowner_),
|
||||
@ -129,7 +130,7 @@ public:
|
||||
int64_t get_last_date() { return last_date_; }
|
||||
int64_t get_last_modify() { return last_modify_; }
|
||||
int64_t get_interval_ts() { return interval_ts_; }
|
||||
int64_t get_max_run_duration() { return max_run_duration_; }
|
||||
int64_t get_max_run_duration() { return (max_run_duration_ == 0) ? 30 : max_run_duration_ ; } // 30s by default
|
||||
|
||||
bool is_broken() { return 0x1 == (flag_ & 0x1); }
|
||||
bool is_running(){ return this_date_ != 0; }
|
||||
|
@ -367,7 +367,7 @@ do { \
|
||||
}
|
||||
|
||||
int ObDBMSSchedTableOperator::get_dbms_sched_job_info(
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const common::ObString &job_name,
|
||||
ObIAllocator &allocator, ObDBMSSchedJobInfo &job_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -378,8 +378,20 @@ int ObDBMSSchedTableOperator::get_dbms_sched_job_info(
|
||||
CK (OB_LIKELY(tenant_id != OB_INVALID_ID));
|
||||
CK (OB_LIKELY(job_id != OB_INVALID_ID));
|
||||
|
||||
OZ (sql.append_fmt("select * from %s where tenant_id = %lu and job = %ld",
|
||||
OB_ALL_TENANT_SCHEDULER_JOB_TNAME, ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id), job_id));
|
||||
if (!job_name.empty()) {
|
||||
OZ (sql.append_fmt("select * from %s where tenant_id = %lu and job_name = \'%.*s\' and job = %ld",
|
||||
OB_ALL_TENANT_SCHEDULER_JOB_TNAME,
|
||||
ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id),
|
||||
job_name.length(),
|
||||
job_name.ptr(),
|
||||
job_id));
|
||||
} else {
|
||||
OZ (sql.append_fmt("select * from %s where tenant_id = %lu and job = %ld",
|
||||
OB_ALL_TENANT_SCHEDULER_JOB_TNAME,
|
||||
ObSchemaUtils::get_extract_tenant_id(tenant_id, tenant_id),
|
||||
job_id));
|
||||
}
|
||||
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
SMART_VAR(ObMySQLProxy::MySQLResult, result) {
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
int update_nextdate(uint64_t tenant_id, ObDBMSSchedJobInfo &job_info);
|
||||
|
||||
int get_dbms_sched_job_info(
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id,
|
||||
uint64_t tenant_id, bool is_oracle_tenant, uint64_t job_id, const common::ObString &job_name,
|
||||
common::ObIAllocator &allocator, ObDBMSSchedJobInfo &job_info);
|
||||
int get_dbms_sched_job_infos_in_tenant(
|
||||
uint64_t tenant_id, bool is_oracle_tenant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user