Lease
Two scheduler instances must not run the same summary. Let one hold time-limited ownership, let it expire after failure, and let the other take over.
Two scheduler instances must not run the same summary. Let one hold time-limited ownership, let it expire after failure, and let the other take over.
Without coordination, the job can run twice.
Control takeover with renewal and expiry: Without coordination, both schedulers can start the daily summary. A lease lets only the current holder run and renew ownership. If it fails or disconnects, a waiting instance must wait for expiry before acquiring a new lease and taking over.
Verify the old-holder risk: Each successful takeover receives a larger fencing token, and the database or target service compares it atomically when accepting a write. Pause A through expiry, let B take over, then resume A and verify that A's stale write is rejected.
Another case: controller leadership: When several controllers can update the same resources, a lease can elect the current leader and be renewed. After failure, a new controller takes over with a newer token so the old leader cannot keep submitting changes.
Use a lease for the daily summary job: an instance acquires time-limited ownership and renews it while running; after expiry, the new holder receives a larger fencing token. Make the database or target service atomically reject writes whose token is older than the current one. Pause instance A until expiry, let B take over and write, then resume A; verify that A's stale write is rejected and only B's result is accepted.