Ch8 Sol2a: booking races, then the room-row lock

Ch8 Sol2a: booking races, then the room-row lock A sequence diagram generated by Archify. SELECT overlaps [9,11)? -> none SELECT overlaps [10,12)? -> none INSERT [9,11); COMMIT INSERT [10,12); COMMIT -> DOUBLE-BOOKED RC txn: check [9,11) -> none RC txn: check [10,12) -> none, no pred-lock INSERT [9,11); COMMIT INSERT [10,12); COMMIT -> doubles AGAIN lock fixed room row R FOR UPDATE same lock request -> BLOCKS check + INSERT [9,11); COMMIT unblocked: sees rival, refuses 409 Check-then-insert: double booking READ COMMITTED: still doubles Fixed room-row lock: serialized Guest A · wants [9,11) · Sequence participant Guest A wants [9,11) Guest B · wants [10,12) · Sequence participant Guest B wants [10,12) PostgreSQL 18 · rooms + reservations · Sequence participant PostgreSQL 18 rooms + reservations Legend main request return security message