Overview of ShedLock
masterShedLock ensures that scheduled tasks are executed at most once at the same time across multiple nodes or threads. When a task starts on one node, it acquires a lock that prevents the same task from executing on other nodes.
Important behaviors:
- Skipping, not waiting: If a task is already running on one node, execution on other nodes is simply skipped; it does not wait for the lock to be released.
- Not a scheduler: ShedLock is a locking mechanism, not a distributed scheduler. It is intended for tasks that can be safely executed repeatedly but should not run in parallel.
- Clock synchronization: ShedLock uses time-based locks and assumes that clocks on all participating nodes are synchronized.
- External coordination: It requires an external store (e.g., JDBC, Mongo, Redis, ZooKeeper) to manage locks.