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

kvserver: add no-op safeguard to TransferLeaseTarget #69931

Conversation

aayushshah15
Copy link
Contributor

@aayushshah15 aayushshah15 commented Sep 8, 2021

kvserver: add no-op safeguard to TransferLeaseTarget

Release justification: adds no-op safeguard

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@aayushshah15 aayushshah15 force-pushed the 20210908_improveCommentTransferLeaseTarget branch from 0fd1712 to 4a10238 Compare September 8, 2021 17:46
Copy link
Contributor

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

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

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


pkg/kv/kvserver/allocator.go, line 1257 at r1 (raw file):

// TransferLeaseTarget returns a suitable replica to transfer the range lease
// to from the provided list. It excludes the current lease holder replica
// unless asked to do otherwise by the checkTransferLeaseSource parameter.

would you mind taking the opportunity to put a comment oncheckTransferLeaseSource? I can't really tell what the deal with it is.


pkg/kv/kvserver/allocator.go, line 1454 at r1 (raw file):

		currentDelta := getQPSDelta(storeQPSMap, existing)
		// NB: If the `bestOption` ends up being the current leaseholder, then the
		// check below will fail since we know that `leaseholderReplQPS` must be

you say the check will fail, but won't it pass?

TBH, I can't really tell what this change is doing (btw, the commit msg says it's comments only, but it's not). So tell me the dealeo, or otherwise perhaps clarify this comment more?

@aayushshah15 aayushshah15 force-pushed the 20210908_improveCommentTransferLeaseTarget branch from 4a10238 to 66c3db6 Compare September 8, 2021 20:58
Copy link
Contributor Author

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

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

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


pkg/kv/kvserver/allocator.go, line 1257 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

would you mind taking the opportunity to put a comment oncheckTransferLeaseSource? I can't really tell what the deal with it is.

done, let me know if its lacking.


pkg/kv/kvserver/allocator.go, line 1454 at r1 (raw file):
The comment was perhaps in the wrong place. See now.

TBH, I can't really tell what this change is doing (btw, the commit msg says it's comments only, but it's not). So tell me the dealeo, or otherwise perhaps clarify this comment more?

See

// Don't bother moving leases whose QPS is below some small fraction of the
// store's QPS (unless the store has extra leases to spare anyway). It's
// just unnecessary churn with no benefit to move leases responsible for,
// for example, 1 qps on a store with 5000 qps.
const minQPSFraction = .001
if replWithStats.qps < localDesc.Capacity.QueriesPerSecond*minQPSFraction &&
float64(localDesc.Capacity.LeaseCount) <= storeList.candidateLeases.mean {
log.VEventf(ctx, 3, "r%d's %.2f qps is too little to matter relative to s%d's %.2f total qps",
replWithStats.repl.RangeID, replWithStats.qps, localDesc.StoreID, localDesc.Capacity.QueriesPerSecond)
continue
}

@aayushshah15 aayushshah15 force-pushed the 20210908_improveCommentTransferLeaseTarget branch from 66c3db6 to 50b80e3 Compare September 8, 2021 21:13
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 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15 and @andreimatei)


pkg/kv/kvserver/allocator.go, line 1454 at r2 (raw file):

		currentDelta := getQPSDelta(storeQPSMap, existing)
		bestOption := getCandidateWithMinQPS(storeQPSMap, existing)
		if bestOption != (roachpb.ReplicaDescriptor{}) && leaseholderReplQPS > 0 &&

This looks good, although I'm left wondering why it was preferable to write like this, as opposed to the more direct

if bestOption != (roachpb.ReplicaDescriptor{}) && bestOption.StoreID != leaseRepl.StoreID()

Release justification: adds no-op safeguard

Release note: None
@aayushshah15 aayushshah15 force-pushed the 20210908_improveCommentTransferLeaseTarget branch from 50b80e3 to 8bcd038 Compare September 9, 2021 19:59
@aayushshah15 aayushshah15 changed the title kvserver: improve a comment in TransferLeaseTarget kvserver: add no-op safeguard to TransferLeaseTarget Sep 9, 2021
Copy link
Contributor Author

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

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

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


pkg/kv/kvserver/allocator.go, line 1454 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

This looks good, although I'm left wondering why it was preferable to write like this, as opposed to the more direct

if bestOption != (roachpb.ReplicaDescriptor{}) && bestOption.StoreID != leaseRepl.StoreID()

Yeah you're right, evidently Andrei found this weird as well. Changed.

@aayushshah15
Copy link
Contributor Author

TFTRs

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 9, 2021

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

Copy link
Contributor

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

@craig
Copy link
Contributor

craig bot commented Sep 9, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 10, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 10, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 10, 2021

Build succeeded:

@craig craig bot merged commit a321f6d into cockroachdb:master Sep 10, 2021
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