new-lock-table maxlocks=10000
----

new-txn txn=txn1 ts=10,1 epoch=0
----

new-txn txn=txn2 ts=10,1 epoch=0
----

# -----------------------------------------------------------------------------
# req1 waits for an unreplicated lock held on key a.
# req2 waits for a replicated lock held on key b.
# req3 waits for a replicated and unreplicated lock held on key c.
# req4 scans all three keys and notices that the lock holder has been pushed.
# It immediately updates the unreplicated-only lock and performs deferred
# resolution on the other locks.
# -----------------------------------------------------------------------------

new-request r=req1 txn=txn1 ts=10,1 spans=none@a
----

new-request r=req2 txn=txn1 ts=10,1 spans=none@b
----

new-request r=req3 txn=txn1 ts=10,1 spans=none@c
----

new-request r=req4 txn=txn1 ts=10,1 spans=none@a,d
----

scan r=req4
----
start-waiting: false

add-discovered r=req4 k=b txn=txn2
----
num=1
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

add-discovered r=req4 k=c txn=txn2
----
num=2
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

new-request r=reqLock txn=txn2 ts=10,1 spans=exclusive@a+exclusive@b+exclusive@c+exclusive@d
----

scan r=reqLock
----
start-waiting: false

acquire r=reqLock k=a durability=u strength=exclusive
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

acquire r=reqLock k=b durability=u strength=exclusive
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent], unrepl [(str: Exclusive seq: 0)]
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

dequeue r=reqLock
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent], unrepl [(str: Exclusive seq: 0)]
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

scan r=req1
----
start-waiting: true

scan r=req2
----
start-waiting: true

scan r=req3
----
start-waiting: true

print
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
   waiting readers:
    req: 3, txn: 00000000-0000-0000-0000-000000000001
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent], unrepl [(str: Exclusive seq: 0)]
   waiting readers:
    req: 4, txn: 00000000-0000-0000-0000-000000000001
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]
   waiting readers:
    req: 5, txn: 00000000-0000-0000-0000-000000000001

pushed-txn-updated txn=txn2 status=pending ts=11,1
----

scan r=req4
----
start-waiting: true

print
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 11.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent], unrepl [(str: Exclusive seq: 0)]
   waiting readers:
    req: 4, txn: 00000000-0000-0000-0000-000000000001
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]
   waiting readers:
    req: 5, txn: 00000000-0000-0000-0000-000000000001

guard-state r=req1
----
new: state=doneWaiting

guard-state r=req2
----
new: state=waitFor txn=txn2 key="b" held=true guard-strength=None

guard-state r=req3
----
new: state=waitFor txn=txn2 key="c" held=true guard-strength=None

guard-state r=req4
----
new: state=doneWaiting
Intents to resolve:
 key="b" txn=00000000 status=PENDING
 key="c" txn=00000000 status=PENDING

update txn=txn2 ts=11,1 epoch=0 span=b
----
num=3
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 11.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 11.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "c"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]
   waiting readers:
    req: 5, txn: 00000000-0000-0000-0000-000000000001

update txn=txn2 ts=11,1 epoch=0 span=c
----
num=2
 lock: "a"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 11.000000000,1, info: unrepl [(str: Exclusive seq: 0)]
 lock: "b"
  holder: txn: 00000000-0000-0000-0000-000000000002 epoch: 0, iso: Serializable, ts: 11.000000000,1, info: unrepl [(str: Exclusive seq: 0)]

guard-state r=req2
----
new: state=doneWaiting

guard-state r=req3
----
new: state=doneWaiting

clear
----
num=0
