Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: improve TestTxnCoordSenderRetries #102086

Merged

Conversation

nvanbenschoten
Copy link
Member

@nvanbenschoten nvanbenschoten commented Apr 22, 2023

This PR improves TestTxnCoordSenderRetries in two ways, in preparation for its use to be expanded to demonstrate the difference in behavior between isolation levels.

use local TxnMetrics in TestTxnCoordSenderRetries

The first commit updates TestTxnCoordSenderRetries to use a local kv.DB with a local TxnMetrics for its test transaction. This allows the test to precisely assert on the metrics without having to worry about other transactions in the system affecting them.

add preemptive refreshes and 1PCs to TestTxnCoordSenderRetries

The second commit adds more testing conditions to TestTxnCoordSenderRetries. Each test now asserts it expectations for preemptive refreshes and for 1-phase commits.

@nvanbenschoten nvanbenschoten requested review from arulajmani and a team April 22, 2023 21:20
@nvanbenschoten nvanbenschoten requested a review from a team as a code owner April 22, 2023 21:20
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
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 2 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 2438 at r2 (raw file):

		},
		{
			name: "write too old with get in the clear",

Unrelated to your patch, how is this case different from the priorReads=true case?


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 2800 at r2 (raw file):

				return err
			},
			expClientRestart: true, // can't refresh

Do you think it's worth add an expectation for RefreshFail and checking it every time there is a client restart?

This commit updates TestTxnCoordSenderRetries to use a local kv.DB with
a local TxnMetrics for its test transaction. This allows the test to
precisely assert on the metrics without having to worry about other
transactions in the system affecting them.

Epic: None
Release note: None
This commit adds more testing conditions to TestTxnCoordSenderRetries.

Epic: None
Release note: None
This was the same as the "write too old with put after prior read" case.

Epic: None
Release note: None
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/improveTxnRestartTest branch from 98f97cf to c59d66a Compare April 30, 2023 02:58
Copy link
Member Author

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

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


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 2438 at r2 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Unrelated to your patch, how is this case different from the priorReads=true case?

Good point, it's the same test. I removed it.


pkg/kv/kvclient/kvcoord/dist_sender_server_test.go line 2800 at r2 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Do you think it's worth add an expectation for RefreshFail and checking it every time there is a client restart?

That's a good idea. I'll do it in a separate PR though, because I have a sequence of stacked changes to this test that would be impacted by the new assertion.

@craig
Copy link
Contributor

craig bot commented Apr 30, 2023

Build succeeded:

@craig craig bot merged commit d11890d into cockroachdb:master Apr 30, 2023
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/improveTxnRestartTest branch April 30, 2023 03:30
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this pull request Apr 30, 2023
This commit adds explicit testing of refresh failures to
`TestTxnCoordSenderRetries`, as suggested in cockroachdb#102086.

Epic: None
Release note: None
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this pull request May 1, 2023
This commit adds explicit testing of refresh failures to
`TestTxnCoordSenderRetries`, as suggested in cockroachdb#102086.

Epic: None
Release note: None
craig bot pushed a commit that referenced this pull request May 1, 2023
102670: kv: test for refresh failures in `TestTxnCoordSenderRetries` r=nvanbenschoten a=nvanbenschoten

This commit adds explicit testing of refresh failures to `TestTxnCoordSenderRetries`, as suggested in #102086.

Epic: None
Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
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