Skip to the content.

1️⃣ Partial Booking → Temporary Hold with Expiry

Example:

User selects seat 12A → Redis key: "seat:12A" = "held" (expires in 5 min)

✅ Pros:


2️⃣ Rollback → Auto-expiry + Compensation (not XA transaction)

Example Flow:

User holds item → TTL expires → Job detects expired hold → Release DB lock → Refund amount

✅ Pros:


3️⃣ Concurrency → Row Lock or Optimistic Versioning

Example:

UPDATE bookings
SET status='confirmed', version=version+1
WHERE id=123 AND version=2;
-- fails if version changed

4️⃣ System Crash Recovery → Cleanup via Cron/Job

Example Flow:

Cron job runs every minute → Checks Redis for expired holds → Releases DB rows/resources → Logs cleanup

✅ Pros:


Putting it all together: Workflow

  1. User requests booking → place temporary hold in Redis with TTL.
  2. User confirms → update DB with optimistic versioning or row lock.
  3. If user cancels or TTL expires → compensation logic releases DB resources.
  4. Cron/cleanup job ensures system crash recovery.