# ADR-002: Seat holds while a passenger pays

- Status: Accepted
- Date: 2024-03-04
- Decided by: Mateo Lindqvist, with Hana Sato

## Context

Between choosing a seat and finishing payment, a passenger can take several minutes. If the seat is
not reserved during that time, another passenger can buy it, and the first one reaches a payment page
for a seat that is gone. If it is reserved forever, abandoned checkouts empty a sailing.

## Decision

Choosing a seat creates a **hold**: a row in the `seat_hold` table that claims the seat under the same
unique constraint as a booking (ADR-001). A seat hold lasts 10 minutes from its creation. Completing
payment converts the hold into a booking in one transaction; the passenger cannot extend a hold.

A background sweeper releases expired holds every 30 seconds. The sweeper deletes holds whose expiry
has passed and that have no payment in progress. A hold with a payment in progress is left for the
payment to settle or fail, so a slow card authorisation never loses the passenger's seat.

## Consequences

- At most 10 minutes of a seat's sale time is lost to an abandoned checkout.
- If the sweeper stops, expired holds accumulate and sailings look fuller than they are. The hold
  backlog runbook covers detecting and clearing this.
- Payments must tell the booking service when they start and finish, which ADR-004 relies on.
