Closed
Description
Bug description
Unlike the JdbcJobExecutionDao, the MongoJobExecutionDao is not "upgrading" the status of the jobExecution that was passed in. This can cause behavior where a job status can go from STOPPING back to STARTED by an asynchronous update.
Environment
Spring Batch version: 5.2.1
Java version:17.0.8
which database you use: Mongo 8.0.1
Steps to reproduce
Steps to reproduce the issue:
- Start a Job using JobLauncher
- Attempt to stop the job using JobOperator::stop
- Verify the status in the jobExecution is updated to STOPPING via the JobExplorer
- Wait for end of step to update JobExecution
- Verify the status in the jobExecution is downgraded to STARTED via the JobExplorer
Expected behavior
I would expect the status to not be allowed to downgrade because that is the behavior of the JDBC implementation.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
denis-yablonsky commentedon Feb 8, 2025
I was able to fix this locally by modifying the synchronizeStatus method to either upgrade the local jobExecution status or update the status in database:
fmbenhassine commentedon Feb 24, 2025
Thank you for reporting this! The current mongo implementation is incorrect compared to the jdbc one. In fact, the jdbc implementation upgrades the job execution in memory while the mongo one updates the job execution in the database. I think I misunderstood the contract when I implemented the method back then (probably the contact should be clearer in that regard).
Anyway, I will fix the mongo implementation and make it consistent with the jdbc one.
Upgrade the job execution status when appropriate in MongoJobExecutio…