System Design Atlas

Shift planning with qualifications and time tracking

07 / 10Worked example

Critical flow

Resolve concurrency when confirming. Which conditions ensure a valid result?

Two planners choose the same person.

Starting point The modules remain separate within the relational datastore.

Assumptions for the example case

A fictional maintenance operation with a defined qualification for each shift. The example requires 11 hours of rest between planned shifts; this is an exercise assumption and does not replace an employment-law review. All quantities, thresholds and operational objectives are illustrative assumptions.

Double synchronisation

Double offline synchronization

The commit is made before the lost response.

Offline app
Scheduling API
Event inbox
Sync Worker
  1. 01 Offline app → Scheduling APIB-47
  2. 02 Scheduling API → Event inboxCommit event
  3. 03 Scheduling API · Local processingResponse lost
  4. 04 Offline app → Scheduling APIB-47 again
  5. 05 Event inbox → Sync WorkerAn event
  6. 06 Sync Worker → Offline appClarification status

Result: The actual time entry is retained; deviations from the plan are reviewed.

B-47 is accepted once; response loss and retries do not duplicate recorded work.

App sends B-47→Commit→Loss of Response→Replay; one event; overlapping booking in clarification.

Commit, response loss and resumption

P-47 free
Confirm two overlapping shifts in orders A/B and B/A → exactly one is confirmed; the other receives a conflict.
B-47 stored
Retry identically, then change occurredAt → one time entry remains; the change causes a conflict. A correction is a separate operation.
The previous shift ends at 16:00
Next start at 02:59:59 / 03:00:00 / 03:00:01 on the following day → only the first violates the 11 h rest period. Qualification valid until 15:59:59 is insufficient; until 16:00 is sufficient.

Resolve concurrency when confirming.

Resolve concurrency when confirming.

Commit interval and rest-period checks together with the allocation.

Two planners choose the same person.

A confirmed, B conflict. B confirmed, A conflict; actual times remain independent of it.

Alternative considered
A preliminary check without a commit-time check allows double assignment.
Trade-off
The losing planner must reschedule.
Reassess
Several people per shift need extended invariants.

Try it yourself

Predict A/B and B/A.

A hint for your attempt

Two planners choose the same person.

Compare with a possible solution
A first
A confirmed, B conflict.
B first
B confirmed, A conflict; actual times remain independent of it.

Apply to your project

How does this principle apply in your own project: Resolve concurrency when confirming.

Step 8: A synchronisation backlog does not establish that no work was done. Which conditions ensure a valid result?