Skip to content

kv: use response keys of ranged writes for lock tracking#121086

Merged
craig[bot] merged 4 commits intocockroachdb:masterfrom
nvb:nvanbenschoten/trackExactKeys
Mar 27, 2024
Merged

kv: use response keys of ranged writes for lock tracking#121086
craig[bot] merged 4 commits intocockroachdb:masterfrom
nvb:nvanbenschoten/trackExactKeys

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Mar 26, 2024

Informs #117978.

This PR updates the txnPipeliner to use the response keys from Get, Scan, ReverseScan, and DeleteRange requests to track pipelined and non-pipelined lock acquisitions / intent writes, instead of assuming that the requests could have left intents anywhere in their request span. This more precise tracking avoid broad ranged intent resolution when more narrow intent resolution is possible. It will also be used by #117978 to track in-flight replicated lock acquisition.

This is a WIP. Some tests need to be updated.

Release note: None

@nvb nvb requested a review from arulajmani March 26, 2024 04:22
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@nvb nvb force-pushed the nvanbenschoten/trackExactKeys branch from c0fff40 to 1136532 Compare March 26, 2024 04:45
arulajmani added a commit to arulajmani/cockroach that referenced this pull request Mar 26, 2024
This is an old test which is tightly coupled with how locks are tracked
on the client. In particular, it expects all ranged locking requests to
use `ResolveIntentRange` requests to resolve their locks; this is
expected to change immminently (see cockroachdb#121086). It's also cumbersome to
change given the randomization it uses to construct batches.

We've got coverage for things being tested here elsewhere. There's some
integration tests in `intent_resolver_integration_test.go` that test
things deterministically. There's also tests for the txn pipeliner and
txn committer that test lock tracking on the client. I'm probably
missing some other examples as well, but deleting this should be safe.

Epic: none

Release note: None
Copy link
Copy Markdown
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Let me know when the tests are updated, and I'll give this one more look and stamp it!

Reviewed 1 of 1 files at r1, 3 of 3 files at r2, 2 of 2 files at r3, 6 of 6 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)


-- commits line 20 at r3:
Nice!


-- commits line 39 at r4:
#121119 should help. I found it very cumbersome to update this test and still keep it meaningful while working on the DeleteRange pipelining PR yesterday, so I punted the problem to this PR (sorry!)


pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go line 758 at r4 (raw file):

						log.Fatalf(ctx, "unexpected multi-key intent pipelined")
					}
					tp.ifWrites.insert(span.Key, seq)

nit: mind adding a TODO somewhere to rename this to ifLocks or something similar?


pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go line 1107 at r4 (raw file):

	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)
	skip.IgnoreLint(t, "WIP")

TIL this is a thing!

craig bot pushed a commit that referenced this pull request Mar 26, 2024
120861: sql/pg_catalog: fix attname for dropped columns r=rafiss a=Jeremyyang920

Previously, the attname columns for dropped columns was padded used a %8d string format. This led to incorrect behavior as it meant a total of 8 '.' characters inclusive of the column ordinal as compared to the PG code base which always pads with 8 '.'. This affected migration tooling since it attempts to verify column names using the returned attname and led to mismatching column reports.

This commit fixes the issue by explicitly setting the padding to 8 '.' to match the PG implementation.

Fixes: #120855

Release note (bug fix): attname for dropped columns is now properly padded with 8 '.' to match PG.

120941: roachprod: add faster restarts, prettier multi-node sql printing r=dt a=dt

A couple minor quality-of-life improvements motivated by working on long-lived, multi-node DRT clusters.

121119: server: delete TestIntentResolution r=arulajmani a=arulajmani

This is an old test which is tightly coupled with how locks are tracked on the client. In particular, it expects all ranged locking requests to use `ResolveIntentRange` requests to resolve their locks; this is expected to change immminently (see #121086). It's also cumbersome to change given the randomization it uses to construct batches.

We've got coverage for things being tested here elsewhere. There's some integration tests in `intent_resolver_integration_test.go` that test things deterministically. There's also tests for the txn pipeliner and txn committer that test lock tracking on the client. I'm probably missing some other examples as well, but deleting this should be safe.

Epic: none

Release note: None

Co-authored-by: Jeremy Yang <jyang@cockroachlabs.com>
Co-authored-by: David Taylor <tinystatemachine@gmail.com>
Co-authored-by: Arul Ajmani <arulajmani@gmail.com>
nvb added 3 commits March 26, 2024 22:30
This commit adds a unit test for ResponseKeyIterate.

Epic: None
Release note: None
This commit updates ResponseKeyIterate to reject a nonsensical case.

Epic: None
Release note: None
This commit updates ResponseKeyIterate to handle DeleteRange requests
that have their ReturnKeys flag set to true.

Epic: None
Release note: None
@nvb nvb force-pushed the nvanbenschoten/trackExactKeys branch from 1136532 to dee7418 Compare March 27, 2024 02:32
Informs cockroachdb#117978.

This commit updates the `txnPipeliner` to use the response keys from
`Get`, `Scan`, `ReverseScan`, and `DeleteRange` requests to track
pipelined and non-pipelined lock acquisitions / intent writes, instead
of assuming that the requests could have left intents anywhere in their
request span. This more precise tracking avoid broad ranged intent
resolution when more narrow intent resolution is possible. It will also
be used by cockroachdb#117978 to track in-flight replicated lock acquisition.

Release note: None
@nvb nvb force-pushed the nvanbenschoten/trackExactKeys branch from dee7418 to 10c4268 Compare March 27, 2024 04:50
@nvb nvb requested a review from arulajmani March 27, 2024 04:51
Copy link
Copy Markdown
Contributor Author

@nvb nvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR! I've addressed the comments and updated all tests. This should be good for another look.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)


-- commits line 39 at r4:

Previously, arulajmani (Arul Ajmani) wrote…

#121119 should help. I found it very cumbersome to update this test and still keep it meaningful while working on the DeleteRange pipelining PR yesterday, so I punted the problem to this PR (sorry!)

Thanks! This was failing before the rebase.


pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go line 758 at r4 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

nit: mind adding a TODO somewhere to rename this to ifLocks or something similar?

Done.

@nvb nvb marked this pull request as ready for review March 27, 2024 04:51
@nvb nvb requested a review from a team as a code owner March 27, 2024 04:51
Copy link
Copy Markdown
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 7 of 7 files at r5, 3 of 3 files at r6, 2 of 2 files at r7, 3 of 6 files at r8.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Mar 27, 2024

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 27, 2024

@craig craig bot merged commit 66517cd into cockroachdb:master Mar 27, 2024
craig bot pushed a commit that referenced this pull request Apr 3, 2024
121088: kv: pipeline replicated lock acquisition r=nvanbenschoten a=nvanbenschoten

Fixes #117978.

Builds upon the foundation laid in [#119975](#119975), [#119933](#119933), [#121065](#121065), and [#121086](#121086).

This commit completes the client-side handling of replicated lock acquisition pipelining. Replicated lock acquisition through `Get`, `Scan`, and `ReverseScan` requests now qualifies to be pipelined. The `txnPipeliner` is updated to track the strength associated with each in-flight write and pass that along to the corresponding `QueryIntentRequest`.

See [benchmark with TPC-C results here](#121088 (comment)).

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants