support date expression in dbms scheduler
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#include "share/ob_all_server_tracer.h"
|
||||
#include "observer/ob_server_struct.h"
|
||||
#include "rootserver/ob_root_service.h"
|
||||
#include "storage/mview/ob_mview_sched_job_utils.h"
|
||||
|
||||
#define TO_TS(second) (1000000L * second)
|
||||
|
||||
@ -40,6 +41,7 @@ using namespace share::schema;
|
||||
using namespace rootserver;
|
||||
using namespace obutil;
|
||||
using namespace obrpc;
|
||||
using namespace storage;
|
||||
|
||||
namespace dbms_scheduler
|
||||
{
|
||||
@ -252,7 +254,19 @@ int64_t ObDBMSSchedJobMaster::calc_next_date(ObDBMSSchedJobInfo &job_info)
|
||||
{
|
||||
int64_t next_date = 0;
|
||||
const int64_t now = ObTimeUtility::current_time();
|
||||
if (job_info.get_interval_ts() == 0) {
|
||||
if (job_info.is_date_expression_job_class()
|
||||
&& !job_info.get_interval().empty()
|
||||
&& (0 != job_info.get_interval().case_compare("null"))) {
|
||||
int64_t next_date_ts = 0;
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(ObMViewSchedJobUtils::calc_date_expression(job_info, next_date_ts))) {
|
||||
LOG_WARN("failed to calc date expression", KR(ret), K(job_info));
|
||||
// error code is ignored
|
||||
next_date = 64060560000000000; // 4000-01-01
|
||||
} else {
|
||||
next_date = next_date_ts;
|
||||
}
|
||||
} else if (job_info.get_interval_ts() == 0) {
|
||||
next_date = 64060560000000000;
|
||||
} else {
|
||||
int64_t N = (now - job_info.get_start_date()) / job_info.get_interval_ts();
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
#include "observer/ob_server_struct.h"
|
||||
#include "observer/dbms_scheduler/ob_dbms_sched_job_utils.h"
|
||||
#include "share/schema/ob_multi_version_schema_service.h"
|
||||
#include "storage/mview/ob_mview_sched_job_utils.h"
|
||||
|
||||
|
||||
namespace oceanbase
|
||||
|
||||
@ -130,15 +130,12 @@ int ObMViewSchedJobUtils::add_scheduler_job(
|
||||
const ObString &exec_env)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t max_end_date_us = -1;
|
||||
if (OB_INVALID_TENANT_ID == tenant_id) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid tenant id", KR(ret), K(tenant_id));
|
||||
} else if (OB_FAIL(share::ObTimeUtility2::str_to_usec("9999-01-01 00:00:00.000", max_end_date_us))) {
|
||||
LOG_WARN("fail to get max_end_date_us", KR(ret));
|
||||
} else {
|
||||
int64_t start_date_us = start_date.is_null() ? ObTimeUtility::current_time() : start_date.get_timestamp();
|
||||
int64_t end_date_us = repeat_interval.empty() ? start_date_us : max_end_date_us;
|
||||
int64_t end_date_us = 64060560000000000; // 4000-01-01
|
||||
HEAP_VAR(ObDBMSSchedJobInfo, job_info) {
|
||||
job_info.tenant_id_ = tenant_id;
|
||||
job_info.job_ = job_id;
|
||||
|
||||
Reference in New Issue
Block a user