diff --git a/pkg/kv/kvserver/concurrency/lock_table.go b/pkg/kv/kvserver/concurrency/lock_table.go index 2bc0d0793f67..4068feb10426 100644 --- a/pkg/kv/kvserver/concurrency/lock_table.go +++ b/pkg/kv/kvserver/concurrency/lock_table.go @@ -2069,7 +2069,7 @@ func (kl *keyLocks) lockStateInfo(now time.Time, rangeID roachpb.RangeID) []roac lockWaiters = append(lockWaiters, lock.Waiter{ WaitingTxn: g.txnMeta(), ActiveWaiter: qg.active, - Strength: lock.Exclusive, + Strength: qg.mode.Strength, WaitDuration: now.Sub(g.mu.curLockWaitStart), }) g.mu.Unlock() diff --git a/pkg/sql/logictest/testdata/logic_test/cluster_locks b/pkg/sql/logictest/testdata/logic_test/cluster_locks index a3e257a4f555..02dc9a051451 100644 --- a/pkg/sql/logictest/testdata/logic_test/cluster_locks +++ b/pkg/sql/logictest/testdata/logic_test/cluster_locks @@ -268,7 +268,7 @@ query TTTTTTTBB colnames SELECT database_name, schema_name, table_name, lock_key_pretty, lock_strength, durability, isolation_level, granted, contended FROM crdb_internal.cluster_locks WHERE range_id=$r1 AND txn_id='$txn4' ---- database_name schema_name table_name lock_key_pretty lock_strength durability isolation_level granted contended -test public t /Table/106/1/"b"/0 Exclusive Unreplicated SERIALIZABLE false true +test public t /Table/106/1/"b"/0 Intent Unreplicated SERIALIZABLE false true query TTTTTTTBB colnames,rowsort SELECT database_name, schema_name, table_name, lock_key_pretty, lock_strength, durability, isolation_level, granted, contended FROM crdb_internal.cluster_locks WHERE range_id=$r2 AND txn_id='$txn3' @@ -431,3 +431,54 @@ awaitstatement iso2 statement ok COMMIT + +user root + +statement ok +BEGIN; +SELECT * FROM t WHERE k = 'a' FOR UPDATE; + +user testuser + +statement ok +BEGIN; +SET enable_shared_locking_for_serializable = true + +statement async share1 +SELECT * FROM t WHERE k = 'a' FOR SHARE; + +user testuser 2 + +statement ok +BEGIN; + +statement async put1 +DELETE FROM t WHERE k = 'a'; + +user root + +# Verify that the waiting transaction reports Shared strength, not Exclusive. +query TTTTTTTBB colnames,retry,rowsort +SELECT database_name, schema_name, table_name, lock_key_pretty, lock_strength, durability, isolation_level, granted, contended FROM crdb_internal.cluster_locks WHERE table_name = 't' +---- +database_name schema_name table_name lock_key_pretty lock_strength durability isolation_level granted contended +test public t /Table/106/1/"a"/0 Exclusive Unreplicated SERIALIZABLE true true +test public t /Table/106/1/"a"/0 Shared Unreplicated SERIALIZABLE false true +test public t /Table/106/1/"a"/0 Intent Unreplicated READ COMMITTED false true + +statement ok +COMMIT + +user testuser + +awaitstatement share1 + +statement ok +COMMIT + +user testuser2 + +awaitstatement put1 + +statement ok +ROLLBACK