Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-2.1: [Fix](Job)Fix redundant job scheduling by preventing same state transitions (e.g., RUNNING → RUNNING) #45495 #45647

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,13 @@ public void alterJobStatus(String jobName, JobStatus jobStatus) throws JobExcept
for (T a : jobMap.values()) {
if (a.getJobName().equals(jobName)) {
try {
if (jobStatus.equals(a.getJobStatus())) {
throw new JobException("Can't change job status to the same status");
}
alterJobStatus(a.getJobId(), jobStatus);
} catch (JobException e) {
throw new JobException("unregister job error, jobName:" + jobName);
throw new JobException("Alter job status error, jobName is %s, errorMsg is %s",
jobName, e.getMessage());
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions regression-test/suites/job_p0/test_base_insert_job.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ suite("test_base_insert_job") {
// check job status and succeed task count is 1
pressJob.size() == 1 && '1' == onceJob.get(0).get(0)
})
assertThrows(Exception) {
sql """
RESUME JOB where jobName='press'
"""
}

sql """
DROP JOB IF EXISTS where jobname = 'past_start_time'
Expand Down Expand Up @@ -299,12 +304,10 @@ suite("test_base_insert_job") {
assert e.getMessage().contains("Invalid interval time unit: years")
}
// assert interval time unit is -1
try {
assertThrows(Exception) {
sql """
CREATE JOB test_error_starts ON SCHEDULE every -1 second comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
"""
} catch (Exception e) {
assert e.getMessage().contains("expecting INTEGER_VALUE")
}

// test keyword as job name
Expand Down
Loading