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: subject query intents to circuit breaker grace period #122255

Merged

Conversation

nvanbenschoten
Copy link
Member

Fixes #121997.

This commit subjects the "pre-commit query intent" sub-batch of a parallel commit to the same circuit breaker grace period as writes (introduced in 9eed3b1). This prevents them from being eagerly cancelled on tripped DistSender circuit breakers, leading to ambiguous errors.

Release note: None

@nvanbenschoten nvanbenschoten requested a review from a team as a code owner April 11, 2024 23:26
@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:

That was quick! A PR in these parts of the code can't be reviewed without minor refactor suggestions, so I left one for you in-line.

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


pkg/kv/kvclient/kvcoord/dist_sender_circuit_breaker.go line 128 at r1 (raw file):

func cbRequestKindFromBatch(ba *kvpb.BatchRequest, withCommit bool) cbRequestKind {
	if ba.IsWrite() || withCommit {
		return cbWriteRequest

It's unfortunate all of the naming here is coupled to read requests and write requests. How do you feel about switching this to something like:

type cbRequestCancellationPolicy int

const (
	cbCancelImmediately cbRequestCancellationPolicy = iota
	cbCancelAfterGracePeriod
	cbNumCancellationPolicies // must be last in list
)

Then we'd be able to add a comment explaining why ba.IsWrite() and withCommit are cancelled after a grace period (without making assumptions about what the caller is using the returned cbRequestKind field for).

@nvanbenschoten nvanbenschoten added the backport-24.1.x Flags PRs that need to be backported to 24.1. label Apr 12, 2024
Fixes cockroachdb#121997.

This commit subjects the "pre-commit query intent" sub-batch of a
parallel commit to the same circuit breaker grace period as writes
(introduced in 9eed3b1). This prevents them from being eagerly
cancelled on tripped DistSender circuit breakers, leading to ambiguous
errors.

Release note: None
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_circuit_breaker.go line 128 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

It's unfortunate all of the naming here is coupled to read requests and write requests. How do you feel about switching this to something like:

type cbRequestCancellationPolicy int

const (
	cbCancelImmediately cbRequestCancellationPolicy = iota
	cbCancelAfterGracePeriod
	cbNumCancellationPolicies // must be last in list
)

Then we'd be able to add a comment explaining why ba.IsWrite() and withCommit are cancelled after a grace period (without making assumptions about what the caller is using the returned cbRequestKind field for).

Good idea. Done.

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

@craig
Copy link
Contributor

craig bot commented Apr 12, 2024

This PR was included in a batch that was canceled, it will be automatically retried

@craig craig bot merged commit 86f20a2 into cockroachdb:master Apr 12, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-24.1.x Flags PRs that need to be backported to 24.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

roachtest: weekly/tpcc/headroom failed
3 participants