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

roachtest: include reads for graceful shutdown test #112926

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

andrewbaptist
Copy link
Contributor

@andrewbaptist andrewbaptist commented Oct 24, 2023

Small changes to the test:

  1. Increase the cluster size from 3 to 6.
  2. Introduce both reads and follower reads.
  3. Increase the length of the test run and the time between
    starts/stops.
  4. Include both reads and writes when measuring QPS.

Epic: none

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch 5 times, most recently from cdd555e to 0b63a73 Compare October 24, 2023 21:24
@andrewbaptist
Copy link
Contributor Author

This isn't quite ready for review, because I need to figure out if I want to tie it to the change to reordering of nodes based on locality before latency.

Also, I don't really like the tangledness of the injecting of the health function into DistSender. It isn't strictly necessary, but I didn't want to do a bigger refactor since we likely want to backport this change. If there is a cleaner way to do this without splitting up the NodeLiveneess code, I would definitely do that.

@andrewbaptist andrewbaptist marked this pull request as ready for review October 24, 2023 21:27
@andrewbaptist andrewbaptist requested a review from a team as a code owner October 24, 2023 21:27
@andrewbaptist andrewbaptist requested a review from a team October 24, 2023 21:27
@andrewbaptist andrewbaptist requested review from a team as code owners October 24, 2023 21:27
@andrewbaptist andrewbaptist requested review from michae2 and removed request for a team October 24, 2023 21:27
@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from 0b63a73 to 9468212 Compare October 25, 2023 15:00
@andrewbaptist andrewbaptist requested a review from a team as a code owner October 25, 2023 15:00
@andrewbaptist andrewbaptist requested review from srosenberg and renatolabs and removed request for a team October 25, 2023 15:00
@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch 3 times, most recently from 1301c0b to aa689b7 Compare October 26, 2023 19:04
@andrewbaptist
Copy link
Contributor Author

@nvanbenschoten I don't think https://github.com/cockroachdb/cockroach/pull/112926/files#diff-104a11712684e520f0affa95e6a053faeb713306a10f69ee99b9729cc9dd1996 is safe (changing the func pointer after construction). It maybe works, since there wouldn't have been any requests sent when this is constructed, but that is just "lucky".

The alternative of refactoring the code to change the construction order is complex and not something I'd want to try and backport. Are there other good alternatives (other than a mutex around the use of this function every time)?

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from aa689b7 to 3fe6804 Compare November 1, 2023 15:43
@andrewbaptist
Copy link
Contributor Author

Test running:

roachprod run $CLUSTER:7 "./cockroach workload run kv --read-percent 50 --follower-read-percent 50 {pgurl:1-5}"

Some graphics of this with and without the change:
Without the change (drain at ~18:01:30)
image

With the change (drain at ~17:52:30)
image

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from 3fe6804 to db3a04d Compare November 1, 2023 19:37
@andrewbaptist andrewbaptist added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Nov 1, 2023
@andrewbaptist
Copy link
Contributor Author

@nvanbenschoten This should be ready for review. I need to look at the failure in TestBoundedStalenessDataDriven but I think the problem is an incorrect assumption in the test. It had failed independently on the same line in a different PR during race, so I don't think this is a new failure.

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch 3 times, most recently from 7931d5c to 84f3086 Compare November 6, 2023 21:02
Copy link
Member

@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.

Reviewed 4 of 11 files at r2, 1 of 4 files at r4, 7 of 7 files at r5.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andrewbaptist, @michae2, @renatolabs, and @srosenberg)


pkg/kv/kvserver/liveness/livenesspb/liveness.go line 274 at r5 (raw file):

	case ReplicaGCQueue:
		return nv.isAlive()
	case DistSender:

The way this turned out is quite nice.


pkg/server/server.go line 550 at r5 (raw file):

	// struct.
	distSender.SetHealthFunc(func(id roachpb.NodeID) bool {
		return nodeLiveness.GetNodeVitalityFromCache(id).IsLive(livenesspb.DistSender)

Calling GetNodeVitalityFromCache O(repl x log(repl)) times per RPC feels like it could come with a sizable performance penalty. Internally, this is acquiring the liveness cache's read lock twice, grabbing an HLC clock reading, and checking the RPC connection health (which itself acquires a few mutexes in gossip and in the RPC context).

Have we measured how expensive a single one of these calls is in a realistic setting (e.g. on a 32-core machine with 10k qps)?

Do we have any other callers of this API on the data path?


pkg/ccl/kvccl/kvfollowerreadsccl/followerreads_test.go line 1268 at r5 (raw file):

		Requests: b.Requests(),
	}
	br.Header.Timestamp = readTime

nit: can't you do b.Header.Timestamp for this, and then still use db.Run?

@andrewbaptist
Copy link
Contributor Author

Looking at the perf data running:

./cockroach workload run kv --duration "1m" --read-percent 100 --follower-read-percent 100 --concurrency 200

WIth the setting disabled (no health check):
33375.0 ops/sec

With the setting enabled:
33445.9 ops/sec

However OptimizeReplicaOrder is much more expensive with it enabled:
Disabled - 0.33%
image
Enabled - 2.17%
image

I'm going to try a few things to reduce this overhead, although I don't think it will go to 0. The biggest cost right now is recomputing it more than once per node (since it is done within sort) and also looking at the connection health.

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch 4 times, most recently from d72c164 to e94642e Compare November 9, 2023 21:43
@andrewbaptist
Copy link
Contributor Author

Closing this for now - the PR #114205 will temporarily supersede this.

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from e94642e to 0f178ae Compare November 14, 2023 17:49
@andrewbaptist andrewbaptist changed the title kvclient: stop reads on followers roachtest: include reads for graceful shutdown test Nov 14, 2023
@andrewbaptist andrewbaptist removed backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Nov 14, 2023
@andrewbaptist andrewbaptist requested review from kvoli and removed request for michae2, srosenberg and renatolabs November 14, 2023 21:42
@andrewbaptist
Copy link
Contributor Author

The only remaining part of this was the change to the roachtest to include follower reads in the testing. I'm changing to @kvoli as he has worked on this test before.

Copy link
Collaborator

@kvoli kvoli 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 1 of 1 files at r10, 25 of 25 files at r11, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andrewbaptist)


-- commits line 4 at r11:
nit: reference the name of the test, since it is changed here.


-- commits line 12 at r11:
nit: rm empty line.


pkg/cmd/roachtest/tests/kv.go line 622 at r11 (raw file):

					case <-ctx.Done():
						return
					case <-time.After(2 * time.Minute):

Q: Why the wait increase?

Copy link
Contributor Author

@andrewbaptist andrewbaptist left a comment

Choose a reason for hiding this comment

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

TFTR!

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


-- commits line 4 at r11:

Previously, kvoli (Austen) wrote…

nit: reference the name of the test, since it is changed here.

Done


-- commits line 12 at r11:

Previously, kvoli (Austen) wrote…

nit: rm empty line.

Done


pkg/cmd/roachtest/tests/kv.go line 622 at r11 (raw file):

Previously, kvoli (Austen) wrote…

Q: Why the wait increase?

This was to make sure we capture any "latent" impacts of the restart. Previously it was restarting before the system was fully healthy (not all caught up and leases rebalanced). A longer wait here prevents this.


pkg/ccl/kvccl/kvfollowerreadsccl/followerreads_test.go line 1268 at r5 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

nit: can't you do b.Header.Timestamp for this, and then still use db.Run?

Thanks - changed.


pkg/kv/kvserver/liveness/livenesspb/liveness.go line 274 at r5 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

The way this turned out is quite nice.

👍


pkg/server/server.go line 550 at r5 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Calling GetNodeVitalityFromCache O(repl x log(repl)) times per RPC feels like it could come with a sizable performance penalty. Internally, this is acquiring the liveness cache's read lock twice, grabbing an HLC clock reading, and checking the RPC connection health (which itself acquires a few mutexes in gossip and in the RPC context).

Have we measured how expensive a single one of these calls is in a realistic setting (e.g. on a 32-core machine with 10k qps)?

Do we have any other callers of this API on the data path?

This was pulled into the other PR - but now this is cached. It turned out the most expensive part of this was the ConnHealth which is done twice without the other changes.

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from 0f178ae to f3da938 Compare December 18, 2023 19:00
@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from f3da938 to 417d149 Compare April 12, 2024 15:11
Small changes to the test kv/gracefuldraining/nodes=3.
1) Increase the cluster size from 3 to 6.
2) Introduce both reads and follower reads.
3) Increase the length of the test run and the time between starts/stops.
4) Include both reads and writes when measuring QPS.

Epic: none

Release note: None
@andrewbaptist
Copy link
Contributor Author

Note that this test will pass, but have long latency periods after each restart due to misrouted follower reads:
image

This is part of the work to fix 24.2, however since this test is currently asserting on throughput not latency we can leave it enabled with follower reads without a high risk of it flaking.

@andrewbaptist andrewbaptist force-pushed the 2023-10-23-follower-read branch from 417d149 to 80bb000 Compare April 12, 2024 16:08
@andrewbaptist
Copy link
Contributor Author

bors r=kvoli

@craig craig bot merged commit 9eb75fc into cockroachdb:master Apr 12, 2024
20 of 22 checks passed
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.

4 participants