Add bookmyshow module: seat booking with hold expiry and payment timeout, naive vs pessimistic vs optimistic inventories, race and deadlock demos, JDBC strategies on H2 (8 test classes, 8 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5YFRisPHrLBR2dRu9
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
deb924febd
commit
c57031aaeb
@@ -0,0 +1,21 @@
|
||||
Two requests for the same two seats, listed in opposite order: H1 asks [A1, A2], H2 asks [A2, A1]
|
||||
=================================================================================================
|
||||
|
||||
PessimisticInventory, AS_REQUESTED (each thread holds one lock, then waits for the other's):
|
||||
stuck until a lock wait timed out (300 ms): true
|
||||
at least one lock wait timed out: true
|
||||
requests that succeeded: at most 1 (never both; which one is timing dependent)
|
||||
Without the timeout both threads would wait forever.
|
||||
|
||||
PessimisticInventory, SORTED (both requests lock A1 first, so one simply waits):
|
||||
requests that succeeded: 1 of 2
|
||||
lock waits that timed out: 0
|
||||
|
||||
OptimisticInventory, AS_REQUESTED (each request takes one seat, then finds the other taken):
|
||||
results: [false, false]
|
||||
A1 / A2 afterwards: AVAILABLE / AVAILABLE (versions v2 / v2: held, then handed back)
|
||||
Both seats are free and both customers were turned away.
|
||||
|
||||
OptimisticInventory, SORTED (both start at A1, so only one can get past the first seat):
|
||||
requests that succeeded: 1 of 2
|
||||
HELD seats afterwards: 2
|
||||
Reference in New Issue
Block a user