Skip to content

SimpleJobOperator.restart(JobExecution) masks the real failure reason with a misleading "job execution already running" message #5439

Closed

Description

@kyungrae

Summary

SimpleJobOperator.restart(JobExecution) wraps every exception thrown by run(...) into a JobRestartException whose message is hardcoded to "job execution already running", discarding the real, accurate reason the job could not be restarted.

Details

TaskExecutorJobLauncher.createJobExecution(...) already throws specific, accurate exceptions for non-restartable conditions. For example, when the previous execution (or one of its step executions) ended in UNKNOWN status:

  throw new JobRestartException("Cannot restart job from UNKNOWN status. "
      + "The last execution ended with a failure that could not be rolled back, "
      + "so it may be dangerous to proceed. Manual intervention is probably necessary.");

But SimpleJobOperator.restart(JobExecution) catches the broad Exception and rebuilds a new message:

  try {
      return run(job, parameters);
  }
  catch (Exception e) {
      throw new JobRestartException(
          String.format(ILLEGAL_STATE_MSG, "job execution already running", jobName, parameters), e);
  }

So the accurate message is demoted to the cause, and the top-level message wrongly says "job execution already running" — even though the job is not running (it's UNKNOWN, or already complete, or had invalid parameters).

Impact

Users and logs see "job execution already running" when the real problem is an UNKNOWN-status execution requiring manual intervention — sending people down the wrong debugging path. The same masking also mislabels JobInstanceAlreadyCompleteException and InvalidJobParametersException.

Expected

restart(JobExecution) should surface the real reason: propagate the launcher's JobRestartException as-is, and only use the "already running" message for the genuinely running case (JobExecutionAlreadyRunningException).

How to reproduce

Restart a JobExecution whose last execution ended in UNKNOWN status (e.g. when a step's final metadata save fails under a concurrent stop). The resulting JobRestartException reports "job execution already running" instead of the UNKNOWN-status reason.

Suggested fix

Replace the broad catch (Exception e) with per-type handling: wrap only JobExecutionAlreadyRunningException as "already running", rethrow JobRestartException unchanged, and wrap JobInstanceAlreadyCompleteException / InvalidJobParametersException with their own messages.

Activity

  1. added 3 commits that reference this issue on Jun 23, 2026
    f443523
    1980878
    102617d
  2. hiSandog commented on Jul 3, 2026

    @hiSandog

    This looks like a straightforward contract bug in SimpleJobOperator.restart(JobExecution): the wrapper exception should add context without replacing the launcher's specific restart reason. A regression test could cover an UNKNOWN previous execution and assert the final JobRestartException message still contains the original “Cannot restart job from UNKNOWN status” text, with the original exception preserved as the cause. That would keep the operator API helpful without changing the launcher behavior.

  3. added this to the 6.0.6 milestone on Aug 14, 2026
  4. added a commit that references this issue on Aug 26, 2026
    3c875a4
  5. added a commit that references this issue on Aug 27, 2026
    9608048
  6. modified the milestones: 6.0.6, 6.1.0-M2 on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions