So I have a scheduled job, locked with ShedLock. When executing, I get the following error:
SQLIntegrityConstraintViolationException: Duplicate entry 'myJob' for key 'PRIMARY'.
The function has the following description:
@Transactional
@Scheduled(cron = "0 0 1 * * MON")
@SchedulerLock(name = "myJob", lockAtLeastFor = "PT5M")
public void myJob() {//Code is not relevant.}
Do you have any idea what this could be about? It feels like the job is running twice, but why doesn't it update the existing column in the DB, but tries to insert a new one?
Update: The job runs fine, meaning just one instance gets to execute the code inside the function. But the other ones throw that exception.
The bean declaration of my LockProvider is as follows:
@Bean
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(
JdbcTemplateLockProvider.Configuration.builder()
.withJdbcTemplate(new JdbcTemplate(dataSource))
.withTableName("shedlock")
.usingDbTime()
.build()
);
}