diff --git a/pkg/kv/kvserver/concurrency/lock_table.go b/pkg/kv/kvserver/concurrency/lock_table.go index 3aac7c72da67..9da8446cfe5d 100644 --- a/pkg/kv/kvserver/concurrency/lock_table.go +++ b/pkg/kv/kvserver/concurrency/lock_table.go @@ -21,7 +21,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv/kvpb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/lock" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/lockspanset" - "github.com/cockroachdb/cockroach/pkg/kv/kvserver/spanset" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" "github.com/cockroachdb/cockroach/pkg/util/buildutil" @@ -137,7 +136,7 @@ func (s waitingState) String() string { // - metrics about lockTable state to export to observability debug pages: // number of locks, number of waiting requests, wait time?, ... -// The btree for a particular SpanScope. +// The btree for a particular key. type treeMu struct { mu syncutil.RWMutex // Protects everything in this struct. @@ -276,7 +275,7 @@ func newLockTable(maxLocks int64, rangeID roachpb.RangeID, clock *hlc.Clock) *lo func (t *lockTableImpl) setMaxLocks(maxLocks int64) { // Check at 5% intervals of the max count. - lockAddMaxLocksCheckInterval := maxLocks / (int64(spanset.NumSpanScope) * 20) + lockAddMaxLocksCheckInterval := maxLocks / int64(20) if lockAddMaxLocksCheckInterval == 0 { lockAddMaxLocksCheckInterval = 1 } @@ -974,6 +973,11 @@ type lockWaitQueue struct { // since those are also shared lockers. In that case it will depend on the // first waiter since that waiter must be desiring a lock that is // incompatible with a shared lock. + // + // TODO(arul): The paragraph above still talks about declaring access on keys + // in terms of SpanAccess instead of lock strength. Switch over this verbiage + // to reference locking/non-locking requests once we support multiple lock + // strengths and add support for joint reservations. reservation *lockTableGuardImpl @@ -1673,10 +1677,10 @@ func (l *lockState) tryActiveWait( // Already reserved by this request. return false, false } - // A non-transactional write request never makes or breaks reservations, - // and only waits for a reservation if the reservation has a lower - // seqNum. Note that `sa == spanset.SpanRead && lockHolderTxn == nil` - // was already checked above. + // A non-transactional write request never makes or breaks reservations, and + // only waits for a reservation if the reservation has a lower seqNum. Note + // that `str == lock.None && lockHolderTxn == nil` was already checked + // above. if g.txn == nil && l.reservation.seqNum > g.seqNum { // Reservation is held by a request with a higher seqNum and g is a // non-transactional request. Ignore the reservation. @@ -2790,34 +2794,30 @@ func (t *lockTableImpl) lockCountForTesting() int64 { // Waiters of removed locks are told to wait elsewhere or that they are done // waiting. func (t *lockTableImpl) tryClearLocks(force bool, numToClear int) { - done := false clearCount := 0 - for i := 0; i < int(spanset.NumSpanScope) && !done; i++ { - t.locks.mu.Lock() - var locksToClear []*lockState - iter := t.locks.MakeIter() - for iter.First(); iter.Valid(); iter.Next() { - l := iter.Cur() - if l.tryClearLock(force) { - locksToClear = append(locksToClear, l) - clearCount++ - if !force && clearCount >= numToClear { - done = true - break - } + t.locks.mu.Lock() + var locksToClear []*lockState + iter := t.locks.MakeIter() + for iter.First(); iter.Valid(); iter.Next() { + l := iter.Cur() + if l.tryClearLock(force) { + locksToClear = append(locksToClear, l) + clearCount++ + if !force && clearCount >= numToClear { + break } } - atomic.AddInt64(&t.locks.numLocks, int64(-len(locksToClear))) - if t.locks.Len() == len(locksToClear) { - // Fast-path full clear. - t.locks.Reset() - } else { - for _, l := range locksToClear { - t.locks.Delete(l) - } + } + atomic.AddInt64(&t.locks.numLocks, int64(-len(locksToClear))) + if t.locks.Len() == len(locksToClear) { + // Fast-path full clear. + t.locks.Reset() + } else { + for _, l := range locksToClear { + t.locks.Delete(l) } - t.locks.mu.Unlock() } + t.locks.mu.Unlock() } // findHighestLockStrengthInSpans returns the highest lock strength specified diff --git a/pkg/kv/kvserver/concurrency/lock_table_test.go b/pkg/kv/kvserver/concurrency/lock_table_test.go index a76a7a9b05f4..339fda061d6d 100644 --- a/pkg/kv/kvserver/concurrency/lock_table_test.go +++ b/pkg/kv/kvserver/concurrency/lock_table_test.go @@ -64,7 +64,7 @@ new-txn txn= ts=[,] epoch= [seq=] Creates a TxnMeta. -new-request r= txn=|none ts=[,] spans=r|w@[,]+... [skip-locked] [max-lock-wait-queue-length=] +new-request r= txn=|none ts=[,] spans=none|shared|update|exclusive|intent@[,]+... [skip-locked] [max-lock-wait-queue-length=] ---- Creates a Request. @@ -112,7 +112,7 @@ add-discovered r= k= txn= [lease-seq=] [consult-finalized- Adds a discovered lock that is discovered by the named request. -check-opt-no-conflicts r= spans=r|w@[,]+... +check-opt-no-conflicts r= spans=none|shared|update|exclusive|intent@[,]+... ---- no-conflicts: @@ -578,21 +578,8 @@ func TestLockTableBasic(t *testing.T) { if txnS == "" { txnS = fmt.Sprintf("unknown txn with ID: %v", state.txn.ID) } - // TODO(arul): We're translating the lock strength back to guardAccess - // for now to reduce test churn. A followup patch should teach these - // datadriven tests to use lock.Strength correctly -- both in its input - // and output. - var sa spanset.SpanAccess - switch state.guardStrength { - case lock.None: - sa = spanset.SpanReadOnly - case lock.Intent: - sa = spanset.SpanReadWrite - default: - t.Fatalf("unexpected guard strength %s", state.guardStrength) - } - return fmt.Sprintf("%sstate=%s txn=%s key=%s held=%t guard-access=%s", - str, typeStr, txnS, state.key, state.held, sa) + return fmt.Sprintf("%sstate=%s txn=%s key=%s held=%t guard-strength=%s", + str, typeStr, txnS, state.key, state.held, state.guardStrength) case "resolve-before-scanning": var reqName string @@ -710,28 +697,27 @@ func scanSpans( lockSpans := &lockspanset.LockSpanSet{} var spansStr string d.ScanArgs(t, "spans", &spansStr) - parts := strings.Split(spansStr, "+") - for _, p := range parts { - if len(p) < 2 || p[1] != '@' { - d.Fatalf(t, "incorrect span with access format: %s", p) + lockSpanStrs := strings.Split(spansStr, "+") + for _, lockSpanStr := range lockSpanStrs { + parts := strings.Split(lockSpanStr, "@") + if len(parts) != 2 { + d.Fatalf(t, "incorrect span with strength format: %s", parts) } - c := p[0] - p = p[2:] + strS := parts[0] + spanStr := parts[1] + str := getStrength(t, d, strS) + // Compute latch span access based on the supplied strength. var sa spanset.SpanAccess - var str lock.Strength - // TODO(arul): Switch the datadriven input to use lock strengths instead. - switch c { - case 'r': + switch str { + case lock.None: sa = spanset.SpanReadOnly - str = lock.None - case 'w': + case lock.Intent: sa = spanset.SpanReadWrite - str = lock.Intent default: - d.Fatalf(t, "incorrect span access: %c", c) + d.Fatalf(t, "unsupported lock strength: %s", str) } - latchSpans.AddMVCC(sa, getSpan(t, d, p), ts) - lockSpans.Add(str, getSpan(t, d, p)) + latchSpans.AddMVCC(sa, getSpan(t, d, spanStr), ts) + lockSpans.Add(str, getSpan(t, d, spanStr)) } return latchSpans, lockSpans } @@ -739,6 +725,10 @@ func scanSpans( func ScanLockStrength(t *testing.T, d *datadriven.TestData) lock.Strength { var strS string d.ScanArgs(t, "strength", &strS) + return getStrength(t, d, strS) +} + +func getStrength(t *testing.T, d *datadriven.TestData, strS string) lock.Strength { switch strS { case "none": return lock.None @@ -748,6 +738,8 @@ func ScanLockStrength(t *testing.T, d *datadriven.TestData) lock.Strength { return lock.Update case "exclusive": return lock.Exclusive + case "intent": + return lock.Intent default: d.Fatalf(t, "unknown lock strength: %s", strS) return 0 diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/acquire_idempotency b/pkg/kv/kvserver/concurrency/testdata/lock_table/acquire_idempotency index c363274841c3..1f47233c6454 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/acquire_idempotency +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/acquire_idempotency @@ -14,7 +14,7 @@ new-lock-table maxlocks=10000 new-txn txn=txn1 ts=10,1 epoch=0 seq=1 ---- -new-request r=req1 txn=txn1 ts=10,1 spans=w@a +new-request r=req1 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req1 @@ -36,7 +36,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=2 ---- -new-request r=req2 txn=txn1 ts=10,1 spans=w@a +new-request r=req2 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req2 @@ -58,7 +58,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=4 ---- -new-request r=req3 txn=txn1 ts=10,1 spans=w@a +new-request r=req3 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req3 @@ -84,7 +84,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=4 ---- -new-request r=req3 txn=txn1 ts=10,1 spans=w@a +new-request r=req3 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req3 @@ -110,7 +110,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=2 ---- -new-request r=req4 txn=txn1 ts=10,1 spans=w@a +new-request r=req4 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req4 @@ -138,7 +138,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=3 ---- -new-request r=req5 txn=txn1 ts=10,1 spans=w@a +new-request r=req5 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req5 @@ -164,7 +164,7 @@ num=1 new-txn txn=txn1 ts=10,1 epoch=0 seq=5 ---- -new-request r=req6 txn=txn1 ts=10,1 spans=w@a +new-request r=req6 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req6 diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered b/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered index bdaa2f6f9da9..ecb102013a38 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered @@ -31,7 +31,7 @@ new-txn txn=txn2 ts=10 epoch=0 new-txn txn=txn3 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10,1 spans=w@a +new-request r=req1 txn=txn1 ts=10,1 spans=intent@a ---- scan r=req1 @@ -50,10 +50,10 @@ num=1 lock: "a" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,1, info: unrepl epoch: 0, seqs: [0] -new-request r=req2 txn=txn2 ts=10,1 spans=w@a +new-request r=req2 txn=txn2 ts=10,1 spans=intent@a ---- -new-request r=req3 txn=txn3 ts=10,1 spans=w@a +new-request r=req3 txn=txn3 ts=10,1 spans=intent@a ---- scan r=req2 @@ -79,7 +79,7 @@ new: state=doneWaiting guard-state r=req3 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=false guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=false guard-strength=Intent # -------------------------------- # Setup complete, test starts here @@ -99,7 +99,7 @@ start-waiting: true guard-state r=req2 ---- -new: state=waitForDistinguished txn=txn3 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn3 key="a" held=true guard-strength=Intent guard-state r=req3 ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered_old_lease b/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered_old_lease index bffa1d5fb515..b4ac091b49f0 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered_old_lease +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/add_discovered_old_lease @@ -7,7 +7,7 @@ new-txn txn=txn1 ts=10 epoch=0 new-txn txn=txn2 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a+r@b+w@c +new-request r=req1 txn=txn1 ts=10 spans=intent@a+none@b+intent@c ---- clear disable diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/basic b/pkg/kv/kvserver/concurrency/testdata/lock_table/basic index 58aa18999e96..b1c0907a0299 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/basic +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/basic @@ -6,7 +6,7 @@ new-txn txn=txn1 ts=10,1 epoch=0 # req1 will acquire locks for txn1 -new-request r=req1 txn=txn1 ts=10,1 spans=r@a,b+w@c,f +new-request r=req1 txn=txn1 ts=10,1 spans=none@a,b+intent@c,f ---- scan r=req1 @@ -51,7 +51,7 @@ time-tick ms=200 # req2 is also for txn1 and will not wait for locks that are held by self. -new-request r=req2 txn=txn1 ts=10,2 spans=w@b,d+r@d,g +new-request r=req2 txn=txn1 ts=10,2 spans=intent@b,d+none@d,g ---- scan r=req2 @@ -89,7 +89,7 @@ new-txn txn=txn2 ts=8,12 epoch=0 ---- # A read request for txn2 does not need to wait for locks held by txn1. -new-request r=req3 txn=txn2 ts=8,12 spans=r@a,g +new-request r=req3 txn=txn2 ts=8,12 spans=none@a,g ---- scan r=req3 @@ -114,7 +114,7 @@ time-tick ms=200 # req4 from txn2 will conflict with locks on b, c since wants to write to [a, d). But does # not conflict with lock on e since wants to read there and the read is at a lower timestamp # than the lock. -new-request r=req4 txn=txn2 ts=8,12 spans=w@a,d+r@d,g +new-request r=req4 txn=txn2 ts=8,12 spans=intent@a,d+none@d,g ---- scan r=req4 @@ -123,7 +123,7 @@ start-waiting: true guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="b" held=true guard-strength=Intent # 3s passes while req4 is waiting on locks on b,c time-tick s=3 @@ -145,7 +145,7 @@ num=3 guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="c" held=true guard-strength=Intent # 1s passes while req4 continues to wait on c (and only has reservation on b) time-tick s=1 @@ -241,7 +241,7 @@ time-tick s=2 guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn3 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn3 key="a" held=true guard-strength=Intent print ---- @@ -368,7 +368,7 @@ time-tick ms=300 # req5 is again from transaction 1. Since it is reading from b, c, and even though txn1 # conflicts with the reservation holder since txn1.ts > txn2.ts, reads don't wait for # reservations. -new-request r=req5 txn=txn1 ts=11,1 spans=r@b+r@c +new-request r=req5 txn=txn1 ts=11,1 spans=none@b+none@c ---- scan r=req5 @@ -399,7 +399,7 @@ time-tick ms=100 # req6 from txn1 conflicts with lock at f, and reservations at b, c. -new-request r=req6 txn=txn1 ts=11,1 spans=r@f+w@b,d +new-request r=req6 txn=txn1 ts=11,1 spans=none@f+intent@b,d ---- scan r=req6 @@ -537,7 +537,7 @@ topklocksbywaitduration: guard-state r=req6 ---- -new: state=waitForDistinguished txn=txn2 key="b" held=false guard-access=write +new: state=waitForDistinguished txn=txn2 key="b" held=false guard-strength=Intent # 250ms passes between req6 and req7 time-tick ms=250 @@ -546,7 +546,7 @@ time-tick ms=250 # req7 from txn3 only wants to write to c -new-request r=req7 txn=txn3 ts=6 spans=w@c +new-request r=req7 txn=txn3 ts=6 spans=intent@c ---- scan r=req7 @@ -571,7 +571,7 @@ start-waiting: true guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn2 key="c" held=false guard-access=write +new: state=waitForDistinguished txn=txn2 key="c" held=false guard-strength=Intent print ---- @@ -737,11 +737,11 @@ num=5 guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn3 key="f" held=true guard-access=read +new: state=waitForDistinguished txn=txn3 key="f" held=true guard-strength=None guard-state r=req6 ---- -old: state=waitForDistinguished txn=txn2 key="b" held=false guard-access=write +old: state=waitForDistinguished txn=txn2 key="b" held=false guard-strength=Intent print ---- @@ -948,11 +948,11 @@ num=4 guard-state r=req6 ---- -new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="b" held=true guard-strength=Intent guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="c" held=true guard-strength=Intent print ---- @@ -1121,7 +1121,7 @@ new: state=doneWaiting guard-state r=req6 ---- -old: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=write +old: state=waitForDistinguished txn=txn2 key="b" held=true guard-strength=Intent print ---- @@ -1377,7 +1377,7 @@ start-waiting: true guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn1 key="c" held=false guard-access=write +new: state=waitForDistinguished txn=txn1 key="c" held=false guard-strength=Intent scan r=req6 ---- @@ -1413,7 +1413,7 @@ time-tick s=15 ---- -new-request r=req8 txn=txn3 ts=6 spans=w@e +new-request r=req8 txn=txn3 ts=6 spans=intent@e ---- scan r=req8 @@ -1422,7 +1422,7 @@ start-waiting: true guard-state r=req8 ---- -new: state=waitForDistinguished txn=txn1 key="e" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="e" held=true guard-strength=Intent dequeue r=req8 ---- @@ -1533,7 +1533,7 @@ topklocksbywaitduration: # All requests have been retired and the lock table is empty. # The following tests multiple requests from the same transaction. -new-request r=req9 txn=txn1 ts=10,1 spans=w@c +new-request r=req9 txn=txn1 ts=10,1 spans=intent@c ---- scan r=req9 @@ -1646,7 +1646,7 @@ topklocksbywaitduration: waitdurationnanos: 0 maxwaitdurationnanos: 0 -new-request r=req10 txn=txn2 ts=8,12 spans=w@c +new-request r=req10 txn=txn2 ts=8,12 spans=intent@c ---- scan r=req10 @@ -1655,9 +1655,9 @@ start-waiting: true guard-state r=req10 ---- -new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="c" held=true guard-strength=Intent -new-request r=req11 txn=txn3 ts=6 spans=w@c +new-request r=req11 txn=txn3 ts=6 spans=intent@c ---- scan r=req11 @@ -1666,9 +1666,9 @@ start-waiting: true guard-state r=req11 ---- -new: state=waitFor txn=txn1 key="c" held=true guard-access=write +new: state=waitFor txn=txn1 key="c" held=true guard-strength=Intent -new-request r=req12 txn=txn2 ts=8,12 spans=w@c +new-request r=req12 txn=txn2 ts=8,12 spans=intent@c ---- scan r=req12 @@ -1677,7 +1677,7 @@ start-waiting: true guard-state r=req12 ---- -new: state=waitFor txn=txn1 key="c" held=true guard-access=write +new: state=waitFor txn=txn1 key="c" held=true guard-strength=Intent print ---- @@ -1796,7 +1796,7 @@ new: state=doneWaiting guard-state r=req11 ---- -new: state=waitForDistinguished txn=txn2 key="c" held=false guard-access=write +new: state=waitForDistinguished txn=txn2 key="c" held=false guard-strength=Intent guard-state r=req12 ---- @@ -1916,7 +1916,7 @@ num=1 guard-state r=req11 ---- -new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="c" held=true guard-strength=Intent # Since req10 that is also txn2 has acquired the lock, req12 does not need to wait here anymore. guard-state r=req12 @@ -2051,7 +2051,7 @@ num=1 guard-state r=req11 ---- -old: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write +old: state=waitForDistinguished txn=txn2 key="c" held=true guard-strength=Intent release txn=txn2 span=b,d ---- @@ -2163,7 +2163,7 @@ num=0 # Tests with non-transactional requests that triggered nil pointer # dereference bugs. -new-request r=req13 txn=txn2 ts=8,12 spans=w@c +new-request r=req13 txn=txn2 ts=8,12 spans=intent@c ---- scan r=req13 @@ -2176,14 +2176,14 @@ num=1 lock: "c" holder: txn: 00000000-0000-0000-0000-000000000002, ts: 8.000000000,12, info: unrepl epoch: 0, seqs: [0] -new-request r=req14 txn=txn1 ts=9,0 spans=w@c +new-request r=req14 txn=txn1 ts=9,0 spans=intent@c ---- scan r=req14 ---- start-waiting: true -new-request r=req15 txn=none ts=10,12 spans=r@c +new-request r=req15 txn=none ts=10,12 spans=none@c ---- scan r=req15 @@ -2202,7 +2202,7 @@ num=1 lock: "c" res: req: 14, txn: 00000000-0000-0000-0000-000000000001, ts: 9.000000000,0, seq: 0 -new-request r=req16 txn=none ts=10,12 spans=r@c +new-request r=req16 txn=none ts=10,12 spans=none@c ---- scan r=req16 @@ -2312,7 +2312,7 @@ topklocksbywaitduration: # transaction that eventually grabs a reservation. Triggered a bug # in not replacing the distinguished waiter. -new-request r=req17 txn=txn1 ts=9,0 spans=w@c+w@d +new-request r=req17 txn=txn1 ts=9,0 spans=intent@c+intent@d ---- scan r=req17 @@ -2341,14 +2341,14 @@ num=2 lock: "d" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 9.000000000,0, info: unrepl epoch: 1, seqs: [0] -new-request r=req18 txn=txn2 ts=10,0 spans=w@c+w@d +new-request r=req18 txn=txn2 ts=10,0 spans=intent@c+intent@d ---- scan r=req18 ---- start-waiting: true -new-request r=req19 txn=txn2 ts=10,0 spans=w@d +new-request r=req19 txn=txn2 ts=10,0 spans=intent@d ---- scan r=req19 @@ -2475,7 +2475,7 @@ num=2 guard-state r=req18 ---- -new: state=waitFor txn=txn1 key="d" held=true guard-access=write +new: state=waitFor txn=txn1 key="d" held=true guard-strength=Intent print ---- @@ -2628,7 +2628,7 @@ num=0 # Reservation can be broken while holding latches because a different # lock is released -new-request r=req20 txn=txn1 ts=10 spans=w@c +new-request r=req20 txn=txn1 ts=10 spans=intent@c ---- scan r=req20 @@ -2647,7 +2647,7 @@ num=1 lock: "c" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 1, seqs: [0] -new-request r=req21 txn=txn1 ts=10 spans=w@d +new-request r=req21 txn=txn1 ts=10 spans=intent@d ---- scan r=req21 @@ -2670,7 +2670,7 @@ num=2 lock: "d" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 1, seqs: [0] -new-request r=req22 txn=txn2 ts=10 spans=w@c+w@d +new-request r=req22 txn=txn2 ts=10 spans=intent@c+intent@d ---- scan r=req22 @@ -2779,7 +2779,7 @@ topklocksbywaitduration: waitdurationnanos: 0 maxwaitdurationnanos: 0 -new-request r=req23 txn=txn3 ts=10 spans=w@d +new-request r=req23 txn=txn3 ts=10 spans=intent@d ---- scan r=req23 diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear index 429b5fe37407..629001d68dc8 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear @@ -14,7 +14,7 @@ new-txn txn=txn3 ts=12,1 epoch=0 # txn1 acquires unreplicated exclusive locks at a and b. -new-request r=req1 txn=txn1 ts=10,1 spans=w@a+w@b +new-request r=req1 txn=txn1 ts=10,1 spans=intent@a+intent@b ---- scan r=req1 @@ -49,7 +49,7 @@ num=2 # In its next request, txn1 discovers a lock at c held by txn2. -new-request r=req2 txn=txn1 ts=10,1 spans=r@c +new-request r=req2 txn=txn1 ts=10,1 spans=none@c ---- scan r=req2 @@ -72,7 +72,7 @@ num=3 # A non-transactional read comes in at a and blocks on the lock. -new-request r=req3 txn=none ts=10,1 spans=r@a +new-request r=req3 txn=none ts=10,1 spans=none@a ---- scan r=req3 @@ -81,11 +81,11 @@ start-waiting: true guard-state r=req3 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None # Similarly, a non-transactional write at a arrives and blocks. -new-request r=req4 txn=none ts=10,1 spans=w@a +new-request r=req4 txn=none ts=10,1 spans=intent@a ---- scan r=req4 @@ -94,11 +94,11 @@ start-waiting: true guard-state r=req4 ---- -new: state=waitFor txn=txn1 key="a" held=true guard-access=write +new: state=waitFor txn=txn1 key="a" held=true guard-strength=Intent # txn3 tries to write to b which also has a lock held, so txn3 has to wait. -new-request r=req5 txn=txn3 ts=12,1 spans=w@b +new-request r=req5 txn=txn3 ts=12,1 spans=intent@b ---- scan r=req5 @@ -107,7 +107,7 @@ start-waiting: true guard-state r=req5 ---- -new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="b" held=true guard-strength=Intent print ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks index 8adc8b4df928..373e37b74c23 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/clear_finalized_txn_locks @@ -21,10 +21,10 @@ new-txn txn=txn4 ts=11,1 epoch=0 # req1 to finish scanning. It needs to resolve the locks held by txn2, txn3. # ----------------------------------------------------------------------------- -new-request r=req1 txn=txn1 ts=10,1 spans=w@a+w@b+w@c+w@d+w@e +new-request r=req1 txn=txn1 ts=10,1 spans=intent@a+intent@b+intent@c+intent@d+intent@e ---- -new-request r=req2 txn=txn4 ts=11,1 spans=w@c +new-request r=req2 txn=txn4 ts=11,1 spans=intent@c ---- scan r=req1 @@ -171,7 +171,7 @@ start-waiting: true guard-state r=req1 ---- -new: state=waitForDistinguished txn=txn4 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn4 key="c" held=true guard-strength=Intent print ---- @@ -263,10 +263,10 @@ num=0 # the list of locks to resolve. # ----------------------------------------------------------------------------- -new-request r=req3 txn=txn1 ts=10,1 spans=w@a+w@b+w@c +new-request r=req3 txn=txn1 ts=10,1 spans=intent@a+intent@b+intent@c ---- -new-request r=req4 txn=txn2 ts=11,1 spans=w@b +new-request r=req4 txn=txn2 ts=11,1 spans=intent@b ---- scan r=req3 @@ -361,10 +361,10 @@ num=0 # req5 notices the finalization (via pushing) and scans again and resolves. # ----------------------------------------------------------------------------- -new-request r=req5 txn=txn1 ts=12,1 spans=w@a+w@b +new-request r=req5 txn=txn1 ts=12,1 spans=intent@a+intent@b ---- -new-request r=req6 txn=txn3 ts=12,1 spans=w@a +new-request r=req6 txn=txn3 ts=12,1 spans=intent@a ---- scan r=req5 @@ -417,11 +417,11 @@ start-waiting: true guard-state r=req6 ---- -new: state=waitFor txn=txn2 key="a" held=true guard-access=write +new: state=waitFor txn=txn2 key="a" held=true guard-strength=Intent guard-state r=req5 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=true guard-strength=Intent print ---- @@ -452,7 +452,7 @@ num=2 guard-state r=req6 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=false guard-access=write +new: state=waitForDistinguished txn=txn1 key="a" held=false guard-strength=Intent guard-state r=req5 ---- @@ -491,10 +491,10 @@ num=0 # reader. # ----------------------------------------------------------------------------- -new-request r=req7 txn=txn1 ts=12,1 spans=w@a+w@b +new-request r=req7 txn=txn1 ts=12,1 spans=intent@a+intent@b ---- -new-request r=req8 txn=txn3 ts=12,1 spans=r@a+r@b +new-request r=req8 txn=txn3 ts=12,1 spans=none@a+none@b ---- scan r=req7 @@ -527,7 +527,7 @@ start-waiting: true guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=true guard-strength=Intent print ---- @@ -586,10 +586,10 @@ num=0 # and resolves txn3 locks before req9. # ----------------------------------------------------------------------------- -new-request r=req9 txn=txn1 ts=12,1 spans=r@a+r@b+r@c+r@d +new-request r=req9 txn=txn1 ts=12,1 spans=none@a+none@b+none@c+none@d ---- -new-request r=req10 txn=txn2 ts=12,1 spans=r@a+r@b +new-request r=req10 txn=txn2 ts=12,1 spans=none@a+none@b ---- scan r=req9 @@ -641,7 +641,7 @@ start-waiting: true guard-state r=req9 ---- -new: state=waitForDistinguished txn=txn4 key="c" held=true guard-access=read +new: state=waitForDistinguished txn=txn4 key="c" held=true guard-strength=None print ---- @@ -695,7 +695,7 @@ num=0 # waiters. # ----------------------------------------------------------------------------- -new-request r=req11 txn=none ts=12,1 spans=w@a +new-request r=req11 txn=none ts=12,1 spans=intent@a ---- scan r=req11 @@ -740,7 +740,7 @@ num=0 # when scanning. # ----------------------------------------------------------------------------- -new-request r=req12 txn=none ts=12,1 spans=r@a +new-request r=req12 txn=none ts=12,1 spans=none@a ---- scan r=req12 diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/disable b/pkg/kv/kvserver/concurrency/testdata/lock_table/disable index c845ca8f79b8..5a6ec45c2fc3 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/disable +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/disable @@ -19,7 +19,7 @@ clear disable ---- num=0 -new-request r=req1 txn=txn1 ts=10,1 spans=w@a+w@c +new-request r=req1 txn=txn1 ts=10,1 spans=intent@a+intent@c ---- scan r=req1 @@ -58,7 +58,7 @@ num=0 enable ---- -new-request r=req2 txn=txn1 ts=10,1 spans=w@a+w@c +new-request r=req2 txn=txn1 ts=10,1 spans=intent@a+intent@c ---- scan r=req2 @@ -83,7 +83,7 @@ start-waiting: true guard-state r=req2 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=true guard-strength=Intent release txn=txn2 span=a ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/discovered_locks_consults_txn_cache b/pkg/kv/kvserver/concurrency/testdata/lock_table/discovered_locks_consults_txn_cache index 82e52e19c0c5..40d0f7b1a05f 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/discovered_locks_consults_txn_cache +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/discovered_locks_consults_txn_cache @@ -14,7 +14,7 @@ new-txn txn=txn3 ts=10 epoch=0 new-txn txn=txn4 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a,e +new-request r=req1 txn=txn1 ts=10 spans=intent@a,e ---- scan r=req1 @@ -99,7 +99,7 @@ start-waiting: true guard-state r=req1 ---- -new: state=waitForDistinguished txn=txn4 key="d" held=true guard-access=write +new: state=waitForDistinguished txn=txn4 key="d" held=true guard-strength=Intent dequeue r=req1 ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/dup_access b/pkg/kv/kvserver/concurrency/testdata/lock_table/dup_access index fcc5dbc8d359..bf953752db14 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/dup_access +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/dup_access @@ -17,7 +17,7 @@ new-txn txn=txn2 ts=10 epoch=0 new-txn txn=txn3 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a+w@b+w@c +new-request r=req1 txn=txn1 ts=10 spans=intent@a+intent@b+intent@c ---- scan r=req1 @@ -36,7 +36,7 @@ num=1 lock: "a" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] -new-request r=req2 txn=txn2 ts=10 spans=w@a+r@a +new-request r=req2 txn=txn2 ts=10 spans=intent@a+none@a ---- scan r=req2 @@ -45,7 +45,7 @@ start-waiting: true guard-state r=req2 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=Intent print ---- @@ -75,7 +75,7 @@ num=0 # broken, but ignores "b" when encounters it as reader. # --------------------------------------------------------------------------------- -new-request r=req3 txn=txn1 ts=10 spans=w@a+w@b+w@c +new-request r=req3 txn=txn1 ts=10 spans=intent@a+intent@b+intent@c ---- scan r=req3 @@ -116,7 +116,7 @@ num=3 lock: "c" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] -new-request r=req4 txn=txn2 ts=10 spans=w@a+w@b +new-request r=req4 txn=txn2 ts=10 spans=intent@a+intent@b ---- scan r=req4 @@ -125,9 +125,9 @@ start-waiting: true guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=Intent -new-request r=req5 txn=txn3 ts=10 spans=w@b+w@c+r@b +new-request r=req5 txn=txn3 ts=10 spans=intent@b+intent@c+none@b ---- scan r=req5 @@ -136,7 +136,7 @@ start-waiting: true guard-state r=req5 ---- -new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="b" held=true guard-strength=Intent print ---- @@ -171,7 +171,7 @@ num=3 guard-state r=req5 ---- -new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="c" held=true guard-strength=Intent print ---- @@ -281,7 +281,7 @@ num=0 # previous test. # --------------------------------------------------------------------------------- -new-request r=req6 txn=txn1 ts=10 spans=w@a+w@b+w@c +new-request r=req6 txn=txn1 ts=10 spans=intent@a+intent@b+intent@c ---- scan r=req6 @@ -322,7 +322,7 @@ num=3 lock: "c" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] -new-request r=req7 txn=txn2 ts=10 spans=w@a+w@b +new-request r=req7 txn=txn2 ts=10 spans=intent@a+intent@b ---- scan r=req7 @@ -331,9 +331,9 @@ start-waiting: true guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=Intent -new-request r=req8 txn=none ts=10 spans=w@b+w@c+r@b +new-request r=req8 txn=none ts=10 spans=intent@b+intent@c+none@b ---- scan r=req8 @@ -342,12 +342,12 @@ start-waiting: true guard-state r=req8 ---- -new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="b" held=true guard-strength=Intent # req9 is just to prevent the lock for "b" from being gc'd and then a new one # created when req7 acquires "b", which due to the old snapshot held by req8 # would not be seen until the next scan. -new-request r=req9 txn=txn2 ts=10 spans=w@b +new-request r=req9 txn=txn2 ts=10 spans=intent@b ---- scan r=req9 @@ -356,7 +356,7 @@ start-waiting: true guard-state r=req9 ---- -new: state=waitFor txn=txn1 key="b" held=true guard-access=write +new: state=waitFor txn=txn1 key="b" held=true guard-strength=Intent print ---- @@ -392,7 +392,7 @@ num=3 guard-state r=req8 ---- -new: state=waitForDistinguished txn=txn1 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="c" held=true guard-strength=Intent print ---- @@ -472,7 +472,7 @@ num=2 guard-state r=req8 ---- -new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=read +new: state=waitForDistinguished txn=txn2 key="b" held=true guard-strength=None print ---- @@ -510,7 +510,7 @@ num=0 # it ignores the lock at "b". # --------------------------------------------------------------------------------- -new-request r=req10 txn=txn1 ts=10 spans=w@a+w@b +new-request r=req10 txn=txn1 ts=10 spans=intent@a+intent@b ---- scan r=req10 @@ -539,7 +539,7 @@ num=2 lock: "b" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] -new-request r=req11 txn=txn2 ts=10 spans=w@a+w@b +new-request r=req11 txn=txn2 ts=10 spans=intent@a+intent@b ---- scan r=req11 @@ -548,9 +548,9 @@ start-waiting: true guard-state r=req11 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=Intent -new-request r=req12 txn=txn3 ts=10 spans=w@b+r@b +new-request r=req12 txn=txn3 ts=10 spans=intent@b+none@b ---- scan r=req12 @@ -559,7 +559,7 @@ start-waiting: true guard-state r=req12 ---- -new: state=waitForDistinguished txn=txn1 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn1 key="b" held=true guard-strength=Intent print ---- @@ -639,7 +639,7 @@ start-waiting: true guard-state r=req12 ---- -new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="b" held=true guard-strength=Intent dequeue r=req11 ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_changes b/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_changes index 5b091edbd325..61f92de60530 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_changes +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_changes @@ -13,7 +13,7 @@ new-txn txn=txn1 ts=10 epoch=0 seq=2 new-txn txn=txn2 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a +new-request r=req1 txn=txn1 ts=10 spans=intent@a ---- acquire r=req1 k=a durability=u @@ -37,7 +37,7 @@ num=1 new-txn txn=txn1 ts=8 epoch=0 seq=3 ---- -new-request r=req2 txn=txn1 ts=8 spans=w@a +new-request r=req2 txn=txn1 ts=8 spans=intent@a ---- acquire r=req2 k=a durability=u @@ -55,7 +55,7 @@ num=1 # of uncontended replicated locks. # --------------------------------------------------------------------------------- -new-request r=reqContend txn=none ts=10 spans=w@a +new-request r=reqContend txn=none ts=10 spans=intent@a ---- scan r=reqContend @@ -84,7 +84,7 @@ num=1 new-txn txn=txn1 ts=10 epoch=1 seq=0 ---- -new-request r=req3 txn=txn1 ts=10 spans=w@a +new-request r=req3 txn=txn1 ts=10 spans=intent@a ---- acquire r=req3 k=a durability=u @@ -102,7 +102,7 @@ num=1 new-txn txn=txn1 ts=6 epoch=2 seq=0 ---- -new-request r=req4 txn=txn1 ts=6 spans=w@a +new-request r=req4 txn=txn1 ts=6 spans=intent@a ---- acquire r=req4 k=a durability=u @@ -115,7 +115,7 @@ num=1 # Reader waits until the timestamp of the lock is updated. # --------------------------------------------------------------------------------- -new-request r=req5 txn=txn2 ts=12 spans=r@a +new-request r=req5 txn=txn2 ts=12 spans=none@a ---- scan r=req5 @@ -124,7 +124,7 @@ start-waiting: true guard-state r=req5 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None print ---- @@ -138,7 +138,7 @@ num=1 new-txn txn=txn1 ts=14 epoch=1 seq=1 ---- -new-request r=req6 txn=txn1 ts=14 spans=w@a +new-request r=req6 txn=txn1 ts=14 spans=intent@a ---- acquire r=req6 k=a durability=r @@ -152,7 +152,7 @@ num=1 guard-state r=req5 ---- -old: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +old: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None acquire r=req6 k=a durability=u ---- @@ -171,7 +171,7 @@ new: state=doneWaiting # that the lock table is used. # --------------------------------------------------------------------------------- -new-request r=req7 txn=txn2 ts=17 spans=r@a +new-request r=req7 txn=txn2 ts=17 spans=none@a ---- scan r=req7 @@ -180,7 +180,7 @@ start-waiting: true guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None add-discovered r=req7 k=a txn=txn1 ---- @@ -193,4 +193,4 @@ num=1 guard-state r=req7 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_dropped b/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_dropped index c99f2ced3d1e..8902fa138b00 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_dropped +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_dropped @@ -10,7 +10,7 @@ new-lock-table maxlocks=10000 new-txn txn=txn1 ts=10 epoch=0 seq=2 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a +new-request r=req1 txn=txn1 ts=10 spans=intent@a ---- acquire r=req1 k=a durability=r @@ -37,7 +37,7 @@ num=0 # causes that lock to be dropped and the readers to be released. # --------------------------------------------------------------------------------- -new-request r=reqContendReader txn=none ts=10 spans=r@a +new-request r=reqContendReader txn=none ts=10 spans=none@a ---- acquire r=req1 k=a durability=u @@ -72,7 +72,7 @@ new: state=doneWaiting # writers causes the lock to be retained. # --------------------------------------------------------------------------------- -new-request r=reqContendWriter txn=none ts=10 spans=w@a +new-request r=reqContendWriter txn=none ts=10 spans=intent@a ---- acquire r=req1 k=a durability=u @@ -113,11 +113,11 @@ num=1 guard-state r=reqContendReader ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None guard-state r=reqContendWriter ---- -new: state=waitFor txn=txn1 key="a" held=true guard-access=write +new: state=waitFor txn=txn1 key="a" held=true guard-strength=Intent clear ---- @@ -144,7 +144,7 @@ num=1 new-txn txn=txn2 ts=10 epoch=0 seq=0 ---- -new-request r=req2 txn=txn2 ts=10 spans=w@b +new-request r=req2 txn=txn2 ts=10 spans=intent@b ---- acquire r=req2 k=b durability=u @@ -155,7 +155,7 @@ num=2 lock: "b" holder: txn: 00000000-0000-0000-0000-000000000002, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] -new-request r=req3 txn=none ts=10 spans=r@a,c +new-request r=req3 txn=none ts=10 spans=none@a,c ---- scan r=req3 @@ -164,7 +164,7 @@ start-waiting: true guard-state r=req3 ---- -new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read +new: state=waitForDistinguished txn=txn1 key="a" held=true guard-strength=None acquire r=req2 k=b durability=r ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/non_active_waiter b/pkg/kv/kvserver/concurrency/testdata/lock_table/non_active_waiter index e360f767962a..8a4921a2b126 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/non_active_waiter +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/non_active_waiter @@ -9,7 +9,7 @@ new-txn txn=txn1 ts=10 epoch=0 new-txn txn=txn2 ts=10 epoch=0 ---- -new-request r=req1 txn=txn1 ts=10 spans=w@a+r@b+w@c +new-request r=req1 txn=txn1 ts=10 spans=intent@a+none@b+intent@c ---- scan r=req1 @@ -64,7 +64,7 @@ num=3 queued writers: active: false req: 1, txn: 00000000-0000-0000-0000-000000000001 -new-request r=req2 txn=txn1 ts=10 spans=w@c +new-request r=req2 txn=txn1 ts=10 spans=intent@c ---- scan r=req2 @@ -95,7 +95,7 @@ start-waiting: true guard-state r=req1 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=true guard-strength=Intent print ---- @@ -131,7 +131,7 @@ num=3 guard-state r=req1 ---- -new: state=waitFor txn=txn2 key="c" held=true guard-access=write +new: state=waitFor txn=txn2 key="c" held=true guard-strength=Intent print ---- @@ -163,7 +163,7 @@ num=3 guard-state r=req1 ---- -new: state=waitForDistinguished txn=txn2 key="b" held=true guard-access=read +new: state=waitForDistinguished txn=txn2 key="b" held=true guard-strength=None guard-state r=req2 ---- diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/non_txn_write b/pkg/kv/kvserver/concurrency/testdata/lock_table/non_txn_write index fa7fe0620cd9..f6afc1ee3f73 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/non_txn_write +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/non_txn_write @@ -11,7 +11,7 @@ new-txn txn=txn3 ts=10 epoch=0 ---- # First locks at a, b, c are acquired by txn1 -new-request r=req1 txn=txn1 ts=10 spans=w@a+w@b+w@c +new-request r=req1 txn=txn1 ts=10 spans=intent@a+intent@b+intent@c ---- scan r=req1 @@ -53,14 +53,14 @@ num=3 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,0, info: unrepl epoch: 0, seqs: [0] # Next, two different transactional requests wait at a and b. -new-request r=req2 txn=txn2 ts=10 spans=w@a +new-request r=req2 txn=txn2 ts=10 spans=intent@a ---- scan r=req2 ---- start-waiting: true -new-request r=req3 txn=txn3 ts=10 spans=w@b +new-request r=req3 txn=txn3 ts=10 spans=intent@b ---- scan r=req3 @@ -69,7 +69,7 @@ start-waiting: true # Next, a non-transactional request that wants to write a, b, c waits at a. -new-request r=req4 txn=none ts=10 spans=w@a+w@b+w@c +new-request r=req4 txn=none ts=10 spans=intent@a+intent@b+intent@c ---- scan r=req4 @@ -78,7 +78,7 @@ start-waiting: true # Next, a transactional request that arrives later than the non-transactional request waits at c -new-request r=req5 txn=txn3 ts=10 spans=w@c +new-request r=req5 txn=txn3 ts=10 spans=intent@c ---- scan r=req5 @@ -131,7 +131,7 @@ new: state=doneWaiting guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn2 key="a" held=false guard-access=write +new: state=waitForDistinguished txn=txn2 key="a" held=false guard-strength=Intent guard-state r=req5 ---- @@ -139,7 +139,7 @@ new: state=doneWaiting # Add another transactional request at a. It will wait behind the non-transactional request. -new-request r=req6 txn=txn1 ts=10 spans=w@a +new-request r=req6 txn=txn1 ts=10 spans=intent@a ---- scan r=req6 @@ -176,7 +176,7 @@ num=3 guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn3 key="b" held=false guard-access=write +new: state=waitForDistinguished txn=txn3 key="b" held=false guard-strength=Intent guard-state r=req6 ---- @@ -249,11 +249,11 @@ start-waiting: true guard-state r=req4 ---- -new: state=waitForDistinguished txn=txn2 key="c" held=true guard-access=write +new: state=waitForDistinguished txn=txn2 key="c" held=true guard-strength=Intent guard-state r=req5 ---- -new: state=waitFor txn=txn2 key="c" held=true guard-access=write +new: state=waitFor txn=txn2 key="c" held=true guard-strength=Intent # Release the lock. The non-transactional request does not acquire the reservation. diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/optimistic b/pkg/kv/kvserver/concurrency/testdata/lock_table/optimistic index 6bdf9490342e..db13e2c92607 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/optimistic +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/optimistic @@ -9,7 +9,7 @@ new-txn txn=txn2 ts=11,1 epoch=0 # req1 will acquire locks for txn1 -new-request r=req1 txn=txn1 ts=10,1 spans=w@c,h +new-request r=req1 txn=txn1 ts=10,1 spans=intent@c,h ---- scan r=req1 @@ -42,7 +42,7 @@ num=2 lock: "g" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,1, info: unrepl epoch: 0, seqs: [0] -new-request r=req2 txn=txn2 ts=11,1 spans=r@a,d +new-request r=req2 txn=txn2 ts=11,1 spans=none@a,d ---- scan r=req2 @@ -61,7 +61,7 @@ num=2 lock: "g" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,1, info: unrepl epoch: 0, seqs: [0] -new-request r=req3 txn=txn2 ts=11,1 spans=r@a,d+r@f,i +new-request r=req3 txn=txn2 ts=11,1 spans=none@a,d+none@f,i ---- scan-opt r=req3 @@ -80,19 +80,19 @@ num=2 lock: "g" holder: txn: 00000000-0000-0000-0000-000000000001, ts: 10.000000000,1, info: unrepl epoch: 0, seqs: [0] -check-opt-no-conflicts r=req3 spans=r@a,c +check-opt-no-conflicts r=req3 spans=none@a,c ---- no-conflicts: true -check-opt-no-conflicts r=req3 spans=r@a,d +check-opt-no-conflicts r=req3 spans=none@a,d ---- no-conflicts: false -check-opt-no-conflicts r=req3 spans=r@a,c+r@f,g +check-opt-no-conflicts r=req3 spans=none@a,c+none@f,g ---- no-conflicts: true -check-opt-no-conflicts r=req3 spans=r@a,c+r@f,h +check-opt-no-conflicts r=req3 spans=none@a,c+none@f,h ---- no-conflicts: false @@ -110,7 +110,7 @@ num=2 # does not trigger a conflict. # --------------------------------------------------------------------------------- -new-request r=req4 txn=txn2 ts=11,1 spans=r@a,i skip-locked +new-request r=req4 txn=txn2 ts=11,1 spans=none@a,i skip-locked ---- scan-opt r=req4 @@ -121,7 +121,7 @@ should-wait r=req4 ---- false -check-opt-no-conflicts r=req4 spans=r@a,i +check-opt-no-conflicts r=req4 spans=none@a,i ---- no-conflicts: true diff --git a/pkg/kv/kvserver/concurrency/testdata/lock_table/query b/pkg/kv/kvserver/concurrency/testdata/lock_table/query index 40d0198f25f7..5d84b5c46ee7 100644 --- a/pkg/kv/kvserver/concurrency/testdata/lock_table/query +++ b/pkg/kv/kvserver/concurrency/testdata/lock_table/query @@ -6,7 +6,7 @@ new-txn txn=txn1 ts=10,1 epoch=0 # req1 will acquire locks for txn1 -new-request r=req1 txn=txn1 ts=10,1 spans=r@a,b+w@c,f +new-request r=req1 txn=txn1 ts=10,1 spans=none@a,b+intent@c,f ---- scan r=req1 @@ -51,7 +51,7 @@ num locks: 1, bytes returned: 41, resume reason: RESUME_UNKNOWN, resume span: