# -------------------------------------------------------------
# Read-only request runs into replicated intent. It informs the
# lock-table and waits for the intent to be resolved.
# -------------------------------------------------------------

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

new-txn name=txn2 ts=12,1 epoch=0
----

new-request name=req1 txn=txn2 ts=12,1
  get key=k
----

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

handle-lock-conflict-error req=req1 lease-seq=1
  lock txn=txn1 key=k
----
[2] handle lock conflict error req1: handled conflicting locks on ‹"k"›, released latches

debug-lock-table
----
num=1
 lock: "k"
  holder: txn: 00000001-0000-0000-0000-000000000000 epoch: 0, iso: Serializable, ts: 10.000000000,1, info: repl [Intent]

sequence req=req1
----
[3] sequence req1: re-sequencing request
[3] sequence req1: acquiring latches
[3] sequence req1: scanning lock table for conflicting locks
[3] sequence req1: waiting in lock wait-queues
[3] sequence req1: lock wait-queue event: wait for txn 00000001 holding lock @ key ‹"k"› (queuedLockingRequests: 0, queuedReaders: 1)
[3] sequence req1: pushing after 0s for: deadlock/liveness detection = true, timeout enforcement = false, priority enforcement = false, wait policy error = false
[3] sequence req1: pushing timestamp of txn 00000001 above 12.000000000,1
[3] sequence req1: blocked on select in concurrency_test.(*cluster).PushTransaction

on-txn-updated txn=txn1 status=aborted
----
[-] update txn: aborting txn1
[3] sequence req1: resolving intent ‹"k"› for txn 00000001 with ABORTED status
[3] sequence req1: lock wait-queue event: done waiting
[3] sequence req1: conflicted with ‹00000001-0000-0000-0000-000000000000› on ‹"k"› for 0.000s
[3] sequence req1: acquiring latches
[3] sequence req1: scanning lock table for conflicting locks
[3] sequence req1: sequencing complete, returned guard

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

reset namespace
----

# -------------------------------------------------------------
# Read-only request runs into replicated intent while the
# lock-table is disabled. The lock-table cannot store the lock,
# so the request retries immediately and redirects when it
# notices the incorrect lease.
# -------------------------------------------------------------

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

new-txn name=txn2 ts=12,1 epoch=0
----

new-request name=req1 txn=txn2 ts=12,1
  get key=k
----

on-lease-updated leaseholder=false lease-seq=2
----
[-] transfer lease: released

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

handle-lock-conflict-error req=req1 lease-seq=2
  lock txn=txn1 key=k
----
[2] handle lock conflict error req1: intent on ‹"k"› discovered but not added to disabled lock table
[2] handle lock conflict error req1: handled conflicting locks on ‹"k"›, released latches

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

# NotLeaseHolderError redirect to new leaseholder.
finish req=req1
----
[-] finish req1: finishing request

reset namespace
----

# -------------------------------------------------------------
# Read-write request runs into replicated intent while the
# lock-table is disabled. The lock-table cannot store the lock,
# so the request retries immediately and redirects when it
# notices the incorrect lease.
# -------------------------------------------------------------

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

new-txn name=txn2 ts=12,1 epoch=0
----

new-request name=req1 txn=txn2 ts=12,1
  put key=k value=v
----

on-lease-updated leaseholder=false lease-seq=2
----
[-] transfer lease: released

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

handle-lock-conflict-error req=req1 lease-seq=2
  lock txn=txn1 key=k
----
[2] handle lock conflict error req1: intent on ‹"k"› discovered but not added to disabled lock table
[2] handle lock conflict error req1: handled conflicting locks on ‹"k"›, released latches

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

# NotLeaseHolderError redirect to new leaseholder.
finish req=req1
----
[-] finish req1: finishing request

reset namespace
----
