Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b5YFRisPHrLBR2dRu9
22 lines
1.1 KiB
Plaintext
22 lines
1.1 KiB
Plaintext
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
|