#  This test sets up the following situation:
#
#   c       <- put  (PoisonPolicyWait; waiting)
#  b---f    <- scan (PoisonPolicyError; waiting)
#   c       <- put  (PoisonPolicyWait; sequenced, poisoned)
#
# When the bottom `c` is poisoned, `b---f` fails fast, and
# the top `c` poisons itself but continues to wait.

new-request txn=none name=put1 ts=10,0 poison-policy=wait
  put key=c value=hi
----

sequence req=put1
----
[1] sequence put1: sequencing request
[1] sequence put1: acquiring latches
[1] sequence put1: scanning lock table for conflicting locks
[1] sequence put1: sequencing complete, returned guard

new-request txn=none name=readbf ts=11,1
  scan key=b endkey=f
----

sequence req=readbf
----
[2] sequence readbf: sequencing request
[2] sequence readbf: acquiring latches
[2] sequence readbf: waiting to acquire read latch ‹{b-f}›@11.000000000,1 for request Scan [‹"b"›,‹"f"›), held by write latch ‹c›@10.000000000,0 for request Put [‹"c"›]
[2] sequence readbf: blocked on select in spanlatch.(*Manager).waitForSignal

new-request txn=none name=put2 ts=11,0 poison-policy=wait
  put key=c value=bar
----

sequence req=put2
----
[3] sequence put2: sequencing request
[3] sequence put2: acquiring latches
[3] sequence put2: waiting to acquire write latch ‹c›@11.000000000,0 for request Put [‹"c"›], held by write latch ‹c›@10.000000000,0 for request Put [‹"c"›]
[3] sequence put2: blocked on select in spanlatch.(*Manager).waitForSignal

poison req=put1
----
[-] poison put1: poisoning request
[2] sequence readbf: sequencing complete, returned error: encountered poisoned latch ‹c›@10.000000000,0
[3] sequence put2: encountered poisoned latch; continuing to wait
[3] sequence put2: blocked on select in spanlatch.(*Manager).waitForSignal

finish req=put1
----
[-] finish put1: finishing request
[3] sequence put2: scanning lock table for conflicting locks
[3] sequence put2: sequencing complete, returned guard

finish req=put2
----
[-] finish put2: finishing request

reset
----
