Here's the point in code that throws the exception:
Code:
synchronized (stepExecution) {
Integer version = new Integer(stepExecution.getVersion().intValue() + 1);
Object[] parameters = new Object[] { stepExecution.getStartTime(), stepExecution.getEndTime(),
stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getTaskCount(),
PropertiesConverter.propertiesToString(stepExecution.getExecutionAttributes().getProperties()),
stepExecution.getExitStatus().isContinuable() ? "Y" : "N",
stepExecution.getExitStatus().getExitCode(), exitDescription, version, stepExecution.getId(),
stepExecution.getVersion() };
int count = jdbcTemplate.update(getUpdateStepExecutionQuery(), parameters, new int[] { Types.TIMESTAMP,
Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.CHAR,
Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER });
// Avoid concurrent modifications...
if (count == 0) {
throw new OptimisticLockingFailureException("Attempt to update step execution id="
+ stepExecution.getId() + " with out of date version (" + stepExecution.getVersion() + ")");
}
stepExecution.incrementVersion();
}
The query that is run will update a step execution where version equals what was passed in. The only way where count can equal 0 is if no rows were updated.
The only two things I can think of that would cause that issue are someone else updating the stepexecution (thus incrementing the version) or the StepExecution not existing. I don't believe any of this code was changed between m3 and m4 though.
Looking at the exception I see this: "Attempt to update step execution id=0 with out of date version (1)"
The JdbcStepDao will *always* insert the step execution for the first time with a version of 1. So, assuming this is the first update of the StepExecution, you can probably rule out the version being the problem. Therefore, I would guess that for some reason the execution was either never inserted (possible transaction issue) or someone tampered with the id (0 seems a bit suspect for the id.)