Demo: a nightly job running once across three replicas
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
run reconciliation exactly once and fence its writes. Prepares MID-032-LAB1.
Draft outline details
Step by step
- Scale
ordersto three replicas; the@Scheduledreconciliation job runs three times. - Add ShedLock with a JDBC lock provider (verify library and version before recording) and annotate with
@SchedulerLock(name = "recon", lockAtMostFor = "10m"). - Run again: one replica executes, others skip.
- Planned mistake: set
lockAtMostForshorter than the job. A second replica starts while the first still runs. Fix: size it above the worst-case runtime and fence the writes. - Add a lock-generation number as a fencing token on the state table.
- Pause the lock holder with
docker pause, let the lease expire, let another run, unpause, and show the stale writes are rejected.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.