rfc: kv lock observability via crdb_locks#75541
rfc: kv lock observability via crdb_locks#75541craig[bot] merged 1 commit intocockroachdb:masterfrom
crdb_locks#75541Conversation
f05e184 to
85fb8ac
Compare
748d486 to
b0b408c
Compare
AlexTalks
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained
docs/RFCS/20220104_crdb_locks.md, line 137 at r2 (raw file):
short-lived and only held as long as a single request, rather than for the life of a transaction, and thus will be less useful in visualizing contention. 4. **We do not track the queries or statements that obtain locks.** This is a
Tagging @cockroachdb/sql-observability as I want to make sure this assumption is valid given current capabilities. IIUC, we don't expose the statements in a given transaction currently, but given that the crdb_locks table is being added, perhaps this is something that could be useful going forward, in order to visualize the statement that caused a transaction to obtain a given lock?
b0b408c to
452b0eb
Compare
maryliag
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @AlexTalks and @maryliag)
docs/RFCS/20220104_crdb_locks.md, line 137 at r2 (raw file):
Previously, AlexTalks (Alex Sarkesian) wrote…
Tagging @cockroachdb/sql-observability as I want to make sure this assumption is valid given current capabilities. IIUC, we don't expose the statements in a given transaction currently, but given that the
crdb_lockstable is being added, perhaps this is something that could be useful going forward, in order to visualize the statement that caused a transaction to obtain a given lock?
Your assumption is correct. Currently we don't track which statement caused a lock.
|
Great to see this! Just a drive-by comment: I've been wanting a tree view of contention, since we often have one long-running txn that's blocking a bunch of others, and those in turn are blocking others again, etc. Some way to easily visualize the entire dependency chain and identify the root transaction causing the pileup seems like it'd be really useful. I think that should be doable with this proposal using a recursive CTE? The only issues I see is that there could be holes in the chain -- both due to the fact that we'll have an inconsistent view of the contention (since we're independently querying the in-memory state of several nodes at different times), and possibly because we perhaps aren't tracking the entire set of involved transactions in the lock table. Thoughts on this? |
Azhng
left a comment
There was a problem hiding this comment.
Nice!
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @AlexTalks, @Azhng, and @maryliag)
docs/RFCS/20220104_crdb_locks.md, line 50 at r3 (raw file):
| Term | Explanation | | ------------------------ | ----------- | | Sequencing | Processing a request through Currency Control. |
nit: s/Currency/Concurrency/
docs/RFCS/20220104_crdb_locks.md, line 58 at r3 (raw file):
| Replicated Lock | A durable lock represented in persistent storage by what is commonly known as an “intent” (`TxnMeta`). This type of lock may or may not be tracked in the in-memory lock table - as mentioned above, a replicated lock is tracked in the lock table if there are wait queues made up of other transactions waiting to acquire this lock. | | Unreplicated Lock | A lock that is only represented in the lock table, and will not persist in case of node failure or lease transfer. Used in `[Get/Scan]ForUpdate`. | | Replicated Lock Keyspace | The separate keyspace in which replicated locks, commonly known as “separated intents”, are stored; in the Local keyspace of a range. This is entirely separate from the Lock Table. Example intent key in the replicated lock keyspace: `/Local/Lock/Intent/Table/56/1/1169/5/3054/0`. |
Is it correct to understand that even thought it's called a "Local" keyspace, the lock is still replicated ?
docs/RFCS/20220104_crdb_locks.md, line 141 at r3 (raw file):
since we do not keep track of the statement history in a given transaction
Are we talking about the current active transaction? Or historical transaction? If it's latter, then we do track list of statements in that transaction.
For former, currently there's no interface to query that interface, but we do have that information stored somewhere (e.g. in connExecutor we keep track of list of statement fingerprint ID of an active txn so far) and it can be possibly exposed via a SQL interface.
docs/RFCS/20220104_crdb_locks.md, line 237 at r3 (raw file):
repeated LockWaiter lock_waiters = 7; }
small style nits: seems like tabs and spaces are mixed up in here
|
Another quick question just for my own understanding. When the lease moves from one node to another, what happens to the in-memory |
AlexTalks
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @AlexTalks, @Azhng, and @maryliag)
docs/RFCS/20220104_crdb_locks.md, line 50 at r3 (raw file):
Previously, Azhng (Archer Zhang) wrote…
nit: s/Currency/Concurrency/
HA, good catch!
docs/RFCS/20220104_crdb_locks.md, line 58 at r3 (raw file):
Previously, Azhng (Archer Zhang) wrote…
Is it correct to understand that even thought it's called a "Local" keyspace, the lock is still replicated ?
That is correct. "Local" in this context means that this key is only addressable within the context of this (replicated) range.
docs/RFCS/20220104_crdb_locks.md, line 141 at r3 (raw file):
Previously, Azhng (Archer Zhang) wrote…
since we do not keep track of the statement history in a given transaction
Are we talking about the current active transaction? Or historical transaction? If it's latter, then we do track list of statements in that transaction.
For former, currently there's no interface to query that interface, but we do have that information stored somewhere (e.g. in
connExecutorwe keep track of list of statement fingerprint ID of an active txn so far) and it can be possibly exposed via a SQL interface.
I was speaking about the statement history of the current active transaction - can clarify that.
As for the ability to possibly expose it, we should schedule some time soon to discuss this as it would be a great enhancement.
docs/RFCS/20220104_crdb_locks.md, line 237 at r3 (raw file):
Previously, Azhng (Archer Zhang) wrote…
small style nits: seems like tabs and spaces are mixed up in here
thanks!
|
Replying to @Azhng:
tl;dr it does not get serialized and sent to the leaseholder, rather things eventually get redirected and queues re-form. Longer explanation: It does not get serialized and sent to the new leaseholder - rather, in the case of a lease transfer, all locks are cleared from the in-memory lock table and the lock table is disabled. On clearing the locks, the waiters are (in order) notified that they no longer need to wait and can continue - however, as they attempt to proceed to command evaluation, any conflicting reads/writes will end up encountering the replicated intent, thus resulting in a One illustrative example exists in the range_state_listener test. Lastly, as this explanation may already imply, this means that unreplicated locks - that is, those used by |
452b0eb to
ceb0408
Compare
|
In response to @erikgrinaker:
I think that the issue about the potential for inconsistency is unavoidable, as I don't think we'd want to block anything to render this table. As for tracking the entire set of involved transactions, I think any that any waiters on a blocking transaction should have that blocking transaction as the lock holder for that key - so if txn1 holds key A but waits on key B, and txn2 holds key B but waits on key C (held by txn3), we should be able to visualize the full dependency chain through the lockholders |
AlexTalks
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)
docs/RFCS/20220104_crdb_locks.md, line 237 at r3 (raw file):
Previously, AlexTalks (Alex Sarkesian) wrote…
thanks!
OK
nvb
left a comment
There was a problem hiding this comment.
Reviewed all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @AlexTalks, @Azhng, @maryliag, and @nvanbenschoten)
docs/RFCS/20220104_crdb_locks.md, line 123 at r4 (raw file):
be acceptable given the use case of this feature. 1. **Inability to display replicated locks without waiters**. Replicated locks
This is framed as a limitation, but that's quite right. This is an intentional design decision. We could scan the persistent lock table and include locks all locks in the response to a QueryLocksRequest if we wanted to. In fact, we very well may want to include that as an option on the request. But for the same reason as in PG, we've deemed the IO cost of doing so to be too expensive for the crdb_internal.crdb_locks table.
docs/RFCS/20220104_crdb_locks.md, line 128 at r4 (raw file):
storage engine. Given that this feature is intended to visualize contention, this may be of minimal concern. 2. **Only read-write transactional lockholders can be displayed.** While
Isn't this also a design decision? We could return the requests in a lockWaitQueue.waitingReaders set if we wanted to. We decided not to do this for pg_locks because it would be confusing to see non-locking operations in that table, given its contract and based on how concurrency control works in Postgres. But are we sure we want to make that decision for crdb_locks, where we have more flexibility to write the script? If read-only requests still block on locks, should they be represented somehow in crdb_locks?
docs/RFCS/20220104_crdb_locks.md, line 170 at r4 (raw file):
CREATE TABLE crdb_internal.crdb_locks ( range_id INT, -- the ID of the range that contains the lock table_id INT, -- the id of the table to which the range with this lock belongs
Should we include database_id and index_id in this table?
docs/RFCS/20220104_crdb_locks.md, line 210 at r4 (raw file):
nit: "```proto"
docs/RFCS/20220104_crdb_locks.md, line 220 at r4 (raw file):
bool active_waiter = 2; SpanAccess access = 3; // [ReadOnly, ReadWrite] uint64 seq_num = 4;
I don't think we should include seq_num in this struct. It's an implementation detail of the lockTable data structure that does not make sense to expose.
docs/RFCS/20220104_crdb_locks.md, line 232 at r4 (raw file):
SpanScope span_scope = 2; // [GLOBAL, LOCAL] Strength lock_strength = 3; Durability = 4;
Durability durability = 4;
docs/RFCS/20220104_crdb_locks.md, line 236 at r4 (raw file):
TxnMeta lockholder_txn_meta = 6; repeated LockWaiter lock_waiters = 7;
Is this list in a specific order?
docs/RFCS/20220104_crdb_locks.md, line 435 at r4 (raw file):
| **For Users/DB Admins** | Contention Events (via SQL, Dashboards) | `crdb_locks` (via SQL) | ## Examples
These are cool to see written out!
docs/RFCS/20220104_crdb_locks.md, line 518 at r4 (raw file):
# Open Questions * Special considerations for tenant SQL pods in Serverless
What is the question here? Do we expect things to behave differently in serverless?
I think that's true. We may want to mention this as a limitation in the RFC and any documentation, but I don't think it's likely to reduce its usefulness -- more of a potential gotcha.
I seem to recall something about the lock table having a bounded size and evicting certain locks when it's full, but I don't remember the details. It's possible (probable even) that we'll pull contended locks into memory even if the lock table is otherwise full. Just worth pointing it out if there is a limitation here. Thanks again working on this -- RFC looks great, and I'm thrilled to see progress on this. |
AlexTalks
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @Azhng, @maryliag, and @nvanbenschoten)
docs/RFCS/20220104_crdb_locks.md, line 123 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
This is framed as a limitation, but that's quite right. This is an intentional design decision. We could scan the persistent lock table and include locks all locks in the response to a
QueryLocksRequestif we wanted to. In fact, we very well may want to include that as an option on the request. But for the same reason as in PG, we've deemed the IO cost of doing so to be too expensive for thecrdb_internal.crdb_lockstable.
Agreed. I think some of the limitations may also be seen as a clarification of semantics. Let me know if you think anything is needed to add here though!
docs/RFCS/20220104_crdb_locks.md, line 128 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Isn't this also a design decision? We could return the requests in a
lockWaitQueue.waitingReadersset if we wanted to. We decided not to do this for pg_locks because it would be confusing to see non-locking operations in that table, given its contract and based on how concurrency control works in Postgres. But are we sure we want to make that decision forcrdb_locks, where we have more flexibility to write the script? If read-only requests still block on locks, should they be represented somehow incrdb_locks?
This limitation was only about lockholders, not waiters - I see no reason not to include read-only lock waiters in the response of course!
docs/RFCS/20220104_crdb_locks.md, line 170 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Should we include
database_idandindex_idin this table?
Sure, can add these!
docs/RFCS/20220104_crdb_locks.md, line 236 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Is this list in a specific order?
You mean in order of readers vs writers? I think it would be ordered: (reservation, waiting readers, waiting writers), but if it would be better to separate these out that could be done.
docs/RFCS/20220104_crdb_locks.md, line 435 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
These are cool to see written out!
Thanks!
docs/RFCS/20220104_crdb_locks.md, line 518 at r4 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
What is the question here? Do we expect things to behave differently in serverless?
The main consideration is how to account for the request in the billing model I think. Or, essentially, if there are any "unknown" unknowns w/r/t Serverless that aren't otherwise accounted for in this document.
ceb0408 to
d260b5b
Compare
This RFC proposes a feature for observing locks (and contention on locks) via a new virtual table called `crdb_internal.crdb_locks`. Release note: None
d260b5b to
8ef27f4
Compare
|
bors r+ |
76611: roachpb: add lock table metadata structures r=AlexTalks a=AlexTalks This change adds the protobuf structures, as well as the method, needed to capture the state of a replica's lock table. This is part of the work coming out of #75541, and is needed to be able to implement the `QueryLocks` RPC. Release justification: (Category 2) The structures created here are entirely new, for the purposes of observability, and do not represent a risk to any existing code or functionality. Release note: None 76897: release: use bazel to build release binaries r=rail,jlinder a=rickystewart This is a pretty large swath of related changes that update the release pipeline to use Bazel for builds. 1. Update `.bazelrc` to add a new `*base` config for each cross-config. The existing cross configs will continue to work as before. Each `*base` config has the same contents as the corresponding cross config EXCEPT the `--workspace_status_command` argument is missing. 2. Stamping. `build/bazelutil/stamp.sh` now takes up to 3 more arguments in addition to the target triple: `build-channel`, `build-tag`, and `build-type`. These are documented in the script and have appropriate defaults for development builds if not specified. 3. Refactor `pkg/release`; the new API is more high-level rather than allowing injecting arbitrary `gotags`, etc. In the future it won't be impossible to add this functionality back in if we want it. 4. Prepare to fork the `Make and Publish Build` build configuration in TC by moving its script into `build/teamcity` and update the script to use Bazel. 5. Update `bazci` to make sure it reads the Windows `geos` libraries from the appropriate location in `bazel-bin`. 6. Update `publish-artifacts` and `publish-provisional-artifacts` to use the new `pkg/release` API. Closes #67147. Closes #67161. Closes #67279. Closes #67322. Release note (general change): Use Bazel to build release binaries Release justification: update release process 77247: server: Allow bypass of tsdump's strict checks r=abarganier a=rimadeodhar tsdump performs strict checks that verify that it has data for exactly the stores it expects to see according to the node->store mapping. It can happen that there legitimately isn't data there, for example when nodes are down during the tsdump window. We still want the strict checks, but now tsdump will defer returning an error and allow restarting with a "-" in lieu of the tsimport file name to display the data anyway. Additionally, cluster settings are set via SET CLUSTER SETTING as opposed to overriding settings directly. Release note (cli change): debug tsdump command allows viewing timeseries data even in case of node failures by rerunning the command with the import filename set to "-". Addresses #75993 Release justification: low risk, high benefit changes to existing functionality 77483: sql/catalog: add return error to RunPostDeserializationChanges r=ajwerner a=rafiss Release justification: low risk enhancement to existing functionality. Release note: None 77493: sql: make session_revival_token.enabled tenant-ro r=otan,jaylim-crl a=rafiss I was hoping to wait for the new cluster setting syntax to be completed, but since it's getting close to the branch cut time I'd rather merge this now so we don't forget at the last minute. Release justification: low risk change to new functionality. Release note: None Co-authored-by: Alex Sarkesian <sarkesian@cockroachlabs.com> Co-authored-by: Ricky Stewart <ricky@cockroachlabs.com> Co-authored-by: rimadeodhar <rima@cockroachlabs.com> Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new funtionality.
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new funtionality.
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new functionality.
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new functionality.
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new functionality.
This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement cockroachdb#75541. Resolves cockroachdb#74833. Release note: None Release justification: Low-risk new functionality.
76998: kv, kvserver: add query locks command r=AlexTalks a=AlexTalks This change adds a new KV API, `QueryLocks`, allowing a client to query the state of a replica's lock table over a provided key span. This exposes the in-memory locks currently managed by Concurrency Control, and is part of the work needed to implement #75541. Resolves #74833. Release note: None Release justification: Low-risk new functionality. Co-authored-by: Alex Sarkesian <sarkesian@cockroachlabs.com>
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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. Release justification: Low risk, high benefit change. Release note (sql change): TBD
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): TBD
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): TBD
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): TBD
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): TBD
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
77876: sql: introduce crdb_internal.cluster_locks virtual table r=AlexTalks a=AlexTalks 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): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted. Co-authored-by: Alex Sarkesian <sarkesian@cockroachlabs.com>
This change introduces the new virtual table `crdb_internal.cluster_locks`, as proposed in the KV Lock Observability RFC (cockroachdb#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 cockroachdb#74834 Release justification: Low risk, high benefit change. Release note (sql change): introducing the `crdb_internal.cluster_locks` virtual table, which exposes the current state of locks on keys tracked by concurrency control. The virtual table displays metadata on locks currently held by transactions, as well as operations waiting to obtain the locks, and as such can be used to visualize active contention. The `VIEWACTIVITY` or `VIEWACTIVITYREDACTED` role option, or the `admin` role, is required to access the virtual table; however, if the user only has the `VIEWACTIVITYREDACTED` role option, the key on which a lock is held will be redacted.
|
I may have missed this but will this information be available after the event? It's OK whilst a TXN is running but typically you need to see this lock information as part of an investigation (for example: we are seeing a lot of contention at 10am each day). In a complex, event driven, system the interactions may be difficult to take apart and even reproduce repeatedly. Recourse to this table after, say a test where contention was experienced, would be very helpful. |
Link to RFC text.
This RFC proposes a feature for observing locks (and contention on
locks) via a new virtual table called
crdb_internal.crdb_locks.Release note: None