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: return destination from AdminScatter #51607

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

pbardea
Copy link
Contributor

@pbardea pbardea commented Jul 20, 2020

This commit updates the AdminScatter request to return the node of the
leaseholder after the scattering for each range that is scattered in the
request.

Release note: None

@pbardea pbardea requested a review from andreimatei July 20, 2020 16:46
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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 @andreimatei, @dt, and @pbardea)


pkg/roachpb/api.proto, line 1549 at r1 (raw file):

    reserved 2;
    // DestinationNodeID is the range's leaseholder after the scattering.
    int32 destination_node_id = 3 [

call this leaseholder.

But let's do this for real. Let's deprecate this message Range, and return a repeated RangeInfo - which is a descriptor and a lease. r.adminScatter can use r.GetDescAndLease() to get a consistent view of both a descriptor and a lease.

@pbardea pbardea force-pushed the admin-scatter-dest branch 4 times, most recently from 411cad4 to b98d4d7 Compare July 22, 2020 22:45
Copy link
Contributor Author

@pbardea pbardea left a comment

Choose a reason for hiding this comment

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

Thank you for taking a look, this is RFAL.

I've gone ahead and deprecated AdminScatter's Range.

scatter.go now constructs AdminScatterResponse_DeprecatedRange based on the RangeInfos if available with a TODO to rework that section to use RangeInfos in 21.1.
I considered requesting the RangeInfos on the batch response header directly (à la RangeStatsResponse) and ripping out DeprecatedRange from scatter.go all together. In the end I opted for this approach since using ReturnRangeInfos isn't a desirable pattern either, and we'd need to keep DeprecatedRange around anyway for backwards compatibility.

Please let me know if you prefer that approach over this one though.

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


pkg/roachpb/api.proto, line 1549 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

call this leaseholder.

But let's do this for real. Let's deprecate this message Range, and return a repeated RangeInfo - which is a descriptor and a lease. r.adminScatter can use r.GetDescAndLease() to get a consistent view of both a descriptor and a lease.

Done.

@pbardea pbardea requested a review from andreimatei July 23, 2020 01:49
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.

This patch doesn't actually use the returned leases, does it?

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


pkg/roachpb/api.proto, line 1546 at r2 (raw file):

  message DeprecatedRange {

it's weird to "deprecate" a struct. I'd leave the message called Range and just rename the field to deprecated_ranges.


pkg/sql/scatter.go, line 125 at r2 (raw file):

	rangeIdx int
	ranges   []roachpb.AdminScatterResponse_DeprecatedRange

make this roachpb.Span


pkg/sql/scatter.go, line 140 at r2 (raw file):

	scatterRes := res.(*roachpb.AdminScatterResponse)
	n.run.rangeIdx = -1
	if scatterRes.RangeInfos != nil {

I'm not sure if this nil check works or if the proto decoder will always allocate a 0-len slice.


pkg/sql/scatter.go, line 142 at r2 (raw file):

	if scatterRes.RangeInfos != nil {
		// TODO(pbardea): In 21.1, remove all references to DeprecatedRange.
		// RangeInfos should also not be nullable then.

I see that you've already made RangeInfos not nullable - in the sense that there's no *[]Range - so this comment is confusing. I'd remove this TODO; the compatibility note below is enough.


pkg/sql/scatter.go, line 152 at r2 (raw file):

			}
		}
	} else {

is this correct? Given how we combine responses, you can get a response with both RangeInfos and DeprecatedRanges. I think DeprecatedRanges will always be a superset of RangeInfos. So I think you want to dedupe and use both. Or, given that you're not using the lease, just use DeprecatedRanges. Or, better yet, make the combine() always populate RangeInfos (use empty leases for the info coming from DeprecatedRanges) and wipe DeprecatedRanges such that above the DistSender one either gets only RangeInfos (when responses were combined or non-combined response from 21.1) or only DeprecatedRanges (non-combined response coming from 20.1) or both as exact duplicates (non-combined response coming from 20.2).

We can also investigate adding a compatibility response translator in the DistSender itself if you feel like it.

@pbardea pbardea force-pushed the admin-scatter-dest branch 3 times, most recently from e69f131 to 6f733b3 Compare July 27, 2020 18:00
Copy link
Contributor Author

@pbardea pbardea 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 @dt)


pkg/roachpb/api.proto, line 1546 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

it's weird to "deprecate" a struct. I'd leave the message called Range and just rename the field to deprecated_ranges.

Done.


pkg/sql/scatter.go, line 125 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

make this roachpb.Span

Done. That's much nicer - thanks.


pkg/sql/scatter.go, line 140 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I'm not sure if this nil check works or if the proto decoder will always allocate a 0-len slice.

Done.


pkg/sql/scatter.go, line 142 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I see that you've already made RangeInfos not nullable - in the sense that there's no *[]Range - so this comment is confusing. I'd remove this TODO; the compatibility note below is enough.

Done.


pkg/sql/scatter.go, line 152 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

is this correct? Given how we combine responses, you can get a response with both RangeInfos and DeprecatedRanges. I think DeprecatedRanges will always be a superset of RangeInfos. So I think you want to dedupe and use both. Or, given that you're not using the lease, just use DeprecatedRanges. Or, better yet, make the combine() always populate RangeInfos (use empty leases for the info coming from DeprecatedRanges) and wipe DeprecatedRanges such that above the DistSender one either gets only RangeInfos (when responses were combined or non-combined response from 21.1) or only DeprecatedRanges (non-combined response coming from 20.1) or both as exact duplicates (non-combined response coming from 20.2).

We can also investigate adding a compatibility response translator in the DistSender itself if you feel like it.

I've updated combine to always populate RangeInfos if it's empty. My original concern was that the range descriptor's range ID would not be set since the DeprecatedRanges only contain span info. Is that an issue?

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! 0 of 0 LGTMs obtained (waiting on @andreimatei, @dt, and @pbardea)


pkg/sql/scatter.go, line 152 at r2 (raw file):

Previously, pbardea (Paul Bardea) wrote…

I've updated combine to always populate RangeInfos if it's empty. My original concern was that the range descriptor's range ID would not be set since the DeprecatedRanges only contain span info. Is that an issue?

well, hopefully nobody else will use RangeInfos until 20.2 is out

@pbardea
Copy link
Contributor Author

pbardea commented Jul 29, 2020

TFTR!
bors r+

AdminScatter now returns the RangeInfos of each range that is scatter by
the request. The returned RangeInfos can be used to determine the
leaseholder of the range after the scattering of the range.

Release note: None
@pbardea
Copy link
Contributor Author

pbardea commented Aug 3, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 3, 2020

Build succeeded:

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