Skip to content
Ameen Abozaid
Planned lessonMID-032-L05

Demo: a nightly job running once across three replicas

  • Lesson 5 of 5
  • Mid-level
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

  1. Scale orders to three replicas; the @Scheduled reconciliation job runs three times.
  2. Add ShedLock with a JDBC lock provider (verify library and version before recording) and annotate with @SchedulerLock(name = "recon", lockAtMostFor = "10m").
  3. Run again: one replica executes, others skip.
  4. Planned mistake: set lockAtMostFor shorter than the job. A second replica starts while the first still runs. Fix: size it above the worst-case runtime and fence the writes.
  5. Add a lock-generation number as a fencing token on the state table.
  6. 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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.