Questions tagged [shedlock]

ShedLock assures that scheduled tasks are executed at most once at the same time.

ShedLock makes sure that scheduled tasks are executed at most once at the same time. If a task is being executed on one node, it acquires a lock which prevents execution of the same task from another node (or thread). If task is already being executed on one node, execution on other nodes does not wait, it is simply skipped.

ShedLock uses external store like Mongo, JDBC database, Redis, Hazelcast, ZooKeeper or anything with a JDBC driver.

https://github.com/lukas-krecan/ShedLock

https://www.baeldung.com/shedlock-spring

66 questions
9
votes
4 answers

Can anyone please explain about the timing mentioned in lockAtLeastFor = "PT1M45S", lockAtMostFor = "PT2M" what is PT here

Can any one please explain about timing defined in lockAtLeastFor and lockAtMostFor. what is PT1M45S and what other parameters it can accept. @Scheduled(cron = "0 0/2 * * * *") @SchedulerLock(name = "TaskScheduler_scheduledTask", lockAtLeastFor…
Kim
  • 305
  • 1
  • 3
  • 14
7
votes
1 answer

How to replace @SchedulerLock with programmatic style

I use spring boot and somewhere in code I have following code: @SchedulerLock(name = "onlineIngestionTask", lockAtMostFor = 900, lockAtLeastFor = 900) public void pullTasksFromRemote() throws InterruptedException { …
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
5
votes
0 answers

Synchronizing @Scheduled method in Spring boot when application in replicated in Kubernetes pods

Example scenario: I have two APIs (Account API and API exposed to user) where Account API will provide me a list of accounts (approx min size 500 and may increase when more accounts are added). I want to fetch the accounts based on a filter and…
5
votes
2 answers

Spring Shedlock timing issue

We are using Spring Shedlock library to run one instance of task at a time in clustered enviroment. But looks like lock is held until specific time (configured by lockAtMostFor attribute If we dont configure it takes default value from spring…
user530158
  • 333
  • 7
  • 18
4
votes
2 answers

ShedLock not lock when Sleuth is present

There is an application that run some process by scheduler, like we have multiple instances we choose shedlock to block other run the same process. However, is not working since sleuth provides an instances of Runnable which is TraceRunnable and the…
nekperu15739
  • 3,311
  • 2
  • 26
  • 25
3
votes
1 answer

Spring ShedLock without Database

I want to disable ShedLock with a configuration yml property. So i don't have to create the table shedlock, if it is not necessary. Is there a way to disable Shedlock usage? I tried to remove @Bean lockProvider but then I got this message: No…
CodeSun
  • 206
  • 2
  • 12
3
votes
4 answers

Spring Boot ShedLock "relation "shedlock" does not exist"

I added ShedLock to my project to prevent working of scheduled job more than one time. I configured it like below but I'm getting "org.postgresql.util.PSQLException: ERROR: relation "shedlock" does not exist" error. This is lockProviderBean: @Bean …
İlkay Gunel
  • 712
  • 2
  • 11
  • 24
2
votes
2 answers

ShedLock with Spring boot with couchbase

Given my Spring boot application code: import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import…
GSSA
  • 21
  • 3
2
votes
1 answer

How to release the lock for scheduler with Shedlock in Spring boot?

I created a scheduler which runs after every 30 seconds. @Scheduled(fixedRateString = "${scheduler.time:30000}") The Shedlock for this has been configured as @EnableSchedulerLock(defaultLockAtMostFor = "PT30S"). I have an entry in the Shedlock…
newLearner
  • 637
  • 1
  • 12
  • 20
2
votes
1 answer

How to call @Scheduled method in only one instance using @PostConstruct

There is job that needs to be done on cron schedule The same logic as in the job must be performed at the start of the spring boot application, therefore @PostConstruct method is used Shedlock is used, since it is planned to run the application in…
2
votes
0 answers

NoClassDefFoundError: net/javacrumbs/shedlock/core/LockProvider

We try to develop a cron batch . I configured a @SchedulerLock anotation but these not work. This code probabably work with more than 1 node. I read in Github that @SchedulerLock may work with these implement, but not work. I tried too , @TryLock…
miguel lopez
  • 87
  • 2
  • 11
2
votes
1 answer

Unable to write unit test for Spring @Scheduler

I have implemented a scheduler with shedlock in my current spring project as follows: @Scheduled(cron = "0 0/1 * * * *") @SchedulerLock(name = "syncData", lockAtMostFor = "${shedlock.myScheduler.lockAtMostFor}", lockAtLeastFor =…
Joy
  • 4,197
  • 14
  • 61
  • 131
2
votes
3 answers

Spring boot schedule task with shedlock not running by its delay

I am using spring boot with shedlock to ensure my schedule task only run in an instance at the same time. Here is my config @Configuration @EnableScheduling @EnableSchedulerLock(mode = EnableSchedulerLock.InterceptMode.PROXY_METHOD,…
user3611168
  • 335
  • 1
  • 6
  • 27
2
votes
1 answer

How to fix Websockets and Shedlock compatibility in Spring Boot application

I have a Spring Boot real-time application that uses Websockets with SockJS. Currently I'm scaling my application with LoadBalancer and two instances. Since there are few cron jobs in the app I need to synchronize it between two server for running…
I. Sokolyk
  • 65
  • 2
  • 8
1
vote
1 answer

Shedlock tries to insert new row in db instead of updating the existing row for the job

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…
1
2 3 4 5