Skip to content

Commit

Permalink
branch-3.0: [Fix](Job)Fix redundant job scheduling by preventing same…
Browse files Browse the repository at this point in the history
… state transitions (e.g., RUNNING → RUNNING) #45495 (#45646)

Cherry-picked from #45495

Co-authored-by: Calvin Kirs <[email protected]>
  • Loading branch information
github-actions[bot] and CalvinKirs authored Dec 19, 2024
1 parent d84ee07 commit e7b9826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit e7b9826

Please sign in to comment.