Critical flow
How does a booking remain traceable in the event of errors?
The local storage and the external payment check run separately in time. An authorization reserves an amount; the later debit is part of the billing. We compare the normal process with a crash and a delayed response.
Starting point From step 6: API, database and worker together carry the booking path; K-17 and R-17 are stored as stable identities.
Assumptions for the example case
Example design: an operator, specifically assigned vehicles, planned periods and a region. Figures are illustrative design assumptions, not company data.
From request for reservation to confirmation
Targeting interruptions
Further reading
| Situation | Proceedings guaranteed |
|---|---|
| Two reservations arrive simultaneously | The database allows at most one effective occupancy for overlapping periods. The other request receives 409. |
| API will fail after committing | A repeat attempt with K-17 finds the same hold. The already stored follow-up order remains processable. |
| Authorization Successful, Worker Crashed Before Storage | The provider reference P-17 and the stable authorization key A-17 allow the status reconciliation. The worker clarifies whether the amount has already been authorized before executing the order again. |
| Success comes after the hold expires | The state machine rejects the confirmation of the elapsed hold. As compensation, the existing authorization is cancelled; an already completed charge is refunded or clarified as a separate billing process. |
| Webhook arrives several times or in another order | Events and state transitions are deduplicated or checked. If there is an objection, the current provider status is queried. |
Two reservations arrive simultaneously
- Proceedings guaranteed
- The database allows at most one effective occupancy for overlapping periods. The other request receives 409.
API will fail after committing
- Proceedings guaranteed
- A repeat attempt with K-17 finds the same hold. The already stored follow-up order remains processable.
Authorization Successful, Worker Crashed Before Storage
- Proceedings guaranteed
- The provider reference P-17 and the stable authorization key A-17 allow the status reconciliation. The worker clarifies whether the amount has already been authorized before executing the order again.
Success comes after the hold expires
- Proceedings guaranteed
- The state machine rejects the confirmation of the elapsed hold. As compensation, the existing authorization is cancelled; an already completed charge is refunded or clarified as a separate billing process.
Webhook arrives several times or in another order
- Proceedings guaranteed
- Events and state transitions are deduplicated or checked. If there is an objection, the current provider status is queried.
Compensation offsets an external effect that already occurred by issuing an appropriate follow-up command. Here, cancelling the authorization releases the reserved amount again. This compensation is pursued as a separate order; a local database rollback cannot reverse the reservation of the amount with the payment provider.
Vehicle access as a second controlled transition
- Recheck before pickup
- Booking, person, driving authorization, current period and operating state must fit. A current or late-ended rental blocks the release.
- Confirm physical unlocking
- An accepted opening order first leads to release_pending. Only the confirmed vehicle response allows active; in case of uncertainty, the order remains under reconciliation.
Terms in this step
- Compensation
- Offset an effect that already occurred with a domain action, for example cancel a payment authorization again.
- State machine
- A model of the allowed status changes and conditions. Here, held is only confirmed with present payment authorization and valid deadline; an expired hold remains excluded from the confirmation.
Try it yourself
The provider has authorized A-17. The worker crashes before saving the response; P-17 is still locally unknown. What happens if the hold has expired?
A hint for your attempt
A-17 was stored before the call. Check the provider over this key and maintain the local deadline.
Compare with a possible solution
- Determine the result
- The new worker compares A-17 according to the provider contract or repeats the same idempotent call. Thus, it receives the existing status and P-17.
- Respect the deadline
- R-17 transitions to expired. A late authorization must not change it to confirmed.
- Compensate the effect
- The worker initiates the cancellation of the authorization. If their outcome remains unclear, a stored clarification order leads to customer service.
Apply to your project
Transfer the error to your own process and note which effect a local rollback cannot take back.