Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: introduce crdb_internal.cluster_locks virtual table
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (#75541), to expose lock contention. This virtual table displays the locks currently tracked in the lock tables in ranges across a cluster, utilizing the KV `QueryLocksRequest` API to gather information on the lock holders as well as the operations waiting on the locks before converting to a user-friendly SQL view that incorporates information about the database, table, schema, and index. For example, ``` root@localhost:26261/defaultdb> select range_id, table_name, lock_key_pretty, txn_id, ts, lock_strength, durability, granted, contended, duration from crdb_internal.cluster_locks; range_id | table_name | lock_key_pretty | txn_id | ts | lock_strength | durability | granted | contended | duration -----------+------------+--------------------------+--------------------------------------+----------------------------+---------------+------------+---------+-----------+------------------ 235 | kv | /Table/115/1/"alex"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.916745 | Exclusive | Replicated | true | true | 00:01:50.607386 235 | kv | /Table/115/1/"alex"/0 | d71ea8eb-21b9-48a0-98b6-82eed84ed76f | 2022-03-26 00:24:02.137125 | None | Replicated | false | true | 00:01:50.607376 235 | kv | /Table/115/1/"bob"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.916745 | Exclusive | Replicated | true | false | 00:01:50.607384 235 | kv | /Table/115/1/"chris"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.916745 | Exclusive | Replicated | true | false | 00:01:50.607383 255 | kv | /Table/115/1/"lauren"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | true | 00:01:50.607757 255 | kv | /Table/115/1/"lauren"/0 | d71ea8eb-21b9-48a0-98b6-82eed84ed76f | 2022-03-26 00:24:02.137125 | None | Replicated | false | true | 00:01:50.60773 255 | kv | /Table/115/1/"marilyn"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607755 255 | kv | /Table/115/1/"mike"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607754 255 | kv | /Table/115/1/"nancy"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607745 255 | kv | /Table/115/1/"noah"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607744 255 | kv | /Table/115/1/"paul"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607744 255 | kv | /Table/115/1/"peter"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.819704 | Exclusive | Replicated | true | false | 00:01:50.607743 256 | kv | /Table/115/1/"sam"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.740235 | Exclusive | Replicated | true | true | 00:01:50.607582 256 | kv | /Table/115/1/"sam"/0 | d71ea8eb-21b9-48a0-98b6-82eed84ed76f | 2022-03-26 00:24:02.137125 | None | Replicated | false | true | 00:01:50.607573 256 | kv | /Table/115/1/"thomas"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.740235 | Exclusive | Replicated | true | false | 00:01:50.607581 256 | kv | /Table/115/1/"zebra"/0 | 7471e67b-bbc3-4dd9-a42f-43ec97949b14 | 2022-03-26 00:23:45.740235 | Exclusive | Replicated | true | false | 00:01:50.60758 (16 rows) ``` This internal table is usable for system tenants as well as secondary tenants. It is also useful in conjunction with other `crdb_internal.cluster_*` tables used for observability, and also can be joined with itself to visualize blocked operations, and the transactions that are blocking them. This feature is gated on v22.1, to ensure that older nodes will not receive `kv.Batch` requests with `QueryLocksRequest`s in them. Closes #74834 Release justification: Low risk, high benefit change. Release note (sql change): TBD
- Loading branch information