On Saturday morning at 10:00 AM, two families arrive at the community banquet hall with catering trucks, each claiming they booked the venue for their child's birthday party. The manual register shows overlapping handwriting, neither family will back down, and the estate manager is caught in the middle.
The Concurrency Nightmare in Web Applications
When software is poorly engineered, two residents can open the booking page at the same second. If Resident A and Resident B hit "Confirm Reservation" within 500 milliseconds of each other, standard database queries will process both requests, creating a catastrophic double-booking.
How Truegate Eliminates Race Conditions
Truegate solves this at the database transaction layer using pessimistic row locking (DB::transaction with lockForUpdate()):
- When a resident selects a time slot, Truegate locks that database row for 10 minutes.
- If another resident attempts to select the same slot, the system immediately displays "Slot reserved by another resident—releasing in 10 minutes if payment is not completed."
- Bookings left unpaid are cancelled automatically, which frees the slot for other residents.
Enforcing Fair-Usage Rules
To prevent a small group of residents from monopolizing popular tennis or badminton courts, Truegate enforces:
- Monthly Prime-Time Caps: Maximum 2 weekend evening slots per flat per month.
- Cancellation Deadlines: Forfeiture of deposit if canceled within 24 hours of the reserved slot.
- Dynamic Guest Pricing: Free slots for resident owners, with automated guest pass fees added to the monthly maintenance bill.