Bug description
Intermittent OptimisticLockingFailureException when starting job using jobOperator.start() with asyncTaskExecutor
Environment
Spring Boot 4.0.0
Spring Batch 6.0.0
Java 21
Steps to reproduce
- Create a new Spring Boot project through the Initializr with Spring Batch and Spring Data Jpa selected.
- Create a configuration class and annotate it with @EnableBatchProcessing and @EnableJdbcJobRepository
- Implement a simple job and create jobOperator using asyncTaskExecutor
- Using jobOperator.start() to start the job
- Intermittent OptimisticLockingFailureException happend in the JdbcJobExecutionDao.updateJobExecution()
- Based on my debug, I found that Job instance is not inserted in the BATCH_JOB_EXECUTION table sometimes but job execution is launched in a new Thread using the asyncTaskExecutor (this is in the TaskExecutorJobLauncher class), and unable to find the job execution record in table then OptimisticLockingFailureException is happend.
Expected behavior
Job should run without issue always.
Bug description
Intermittent OptimisticLockingFailureException when starting job using jobOperator.start() with asyncTaskExecutor
Environment
Spring Boot 4.0.0
Spring Batch 6.0.0
Java 21
Steps to reproduce
Expected behavior
Job should run without issue always.