Skip to content

Running a job causes retrieval of full history of job executions #4169

Closed

Description

@glaz666

When running a job via SimpleJobLauncher#run , it creates new JobExecution, but retrieves all executions of the job from database:

List<JobExecution> executions = jobExecutionDao.findJobExecutions(jobInstance);

The approach to create new executions should be revised towards constant timing and constant memory usage regardless of how many times a job was executed in past.

My proposal would be to change a query to limit response size, e.g. last execution is enough to make a decision if running job instance exist.

Activity

  1. ioanadinuit commented on Feb 10, 2023

    @ioanadinuit

    Hi, is there any plan to make this enhancement? I would be happy to contribute.

  2. fmbenhassine commented on Feb 17, 2023

    @fmbenhassine
    Contributor

    @glaz666 I think the retrieval of job executions is required to validate a few conditions (see here). But if we find a way to improve the performance of that part without introducing any regression, I am all for it!

    @ioanadinuit Thank you for your offer to help! Sure, you are welcome to contribute if you want.

  3. fmbenhassine commented on Apr 5, 2023

    @fmbenhassine
    Contributor

    A good start on this issue is to provide a minimal example that we can use to validate the performance issue and also as a comparison baseline with the improved version.

  4. added
    status: need-help-to-reproduce
    on Apr 5, 2023
  5. jjh75607 commented on Aug 23, 2026

    @jjh75607
    Contributor

    The minimal example and comparison baseline you asked for are attached to #5495, where the
    statement count still grows with the number of past executions on 5.2.2 and does so about
    eight times more steeply on 6.0.4. The retrieval has moved since this issue was filed: it
    now happens in the restart check in TaskExecutorJobLauncher.createJobExecution, which
    reads the history through jobRepository.getJobExecutions(jobInstance).

  6. added this to the 6.1.0-RC1 milestone on Oct 1, 2026
  7. added
    for: backport-to-6.0.x
    and removed
    status: need-help-to-reproduce
    on Oct 1, 2026
  8. added a commit that references this issue on Oct 1, 2026
    4aa77ea
  9. added a commit that references this issue on Oct 2, 2026
    c702081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: backport-to-6.0.xin: corerelated-to: performancetype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions