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

sql: add TenantStatusServer.NodeLocality to support crdb_internal.ranges{_no_leases} for secondary tenants #92293

Merged
merged 1 commit into from
Nov 29, 2022
Merged

sql: add TenantStatusServer.NodeLocality to support crdb_internal.ranges{_no_leases} for secondary tenants #92293

merged 1 commit into from
Nov 29, 2022

Conversation

ecwall
Copy link
Contributor

@ecwall ecwall commented Nov 21, 2022

This PR adds a new node locality lookup KV admin function which is
used by crdb_internal.ranges{_no_leases} and SHOW RANGES to
work for secondary tenants.

Release note: None

Epic: CRDB-14522

@ecwall ecwall requested review from a team as code owners November 21, 2022 22:02
@ecwall ecwall requested a review from a team November 21, 2022 22:02
@ecwall ecwall requested a review from a team as a code owner November 21, 2022 22:02
@ecwall ecwall requested a review from a team November 21, 2022 22:02
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ecwall ecwall requested a review from knz November 21, 2022 22:02
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

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


-- commits line 13 at r1:
nit: you do not need to include the full URL here, just Epic: CRDB-14522 is sufficient.


pkg/server/status.go line 1384 at r1 (raw file):

}

// NodeLocality implements the serverpb.Status interface

nit: period at end of comment.


pkg/server/serverpb/status.go line 84 at r1 (raw file):

// the SQL system to query for the node locality of a given node ID.
// It is available for tenants.
type NodeLocalityServer interface {

Could you discuss with @dhartunian whether this interface can be merged with those above (in fact, also whether the others could be merged together). At this point I do not understand why we have so many interfaces and why they need to be separate.

Copy link
Collaborator

@dhartunian dhartunian 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 @ecwall)


pkg/server/serverpb/status.go line 84 at r1 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

Could you discuss with @dhartunian whether this interface can be merged with those above (in fact, also whether the others could be merged together). At this point I do not understand why we have so many interfaces and why they need to be separate.

@ecwall I agree in this case that we should avoid introducing a new interface. It looks like RegionsServer above and TenantStatusServer are used in the same contexts so I'd suggest either:

  • merging all 3 into TenantStatusServer to unify all the stuff tenants need from a Connector
    or
  • add your NodeLocality method to TenantStatusServer and put a TODO on RegionsServer to merge later

I don't see anything in particular gained from a separate interface here. It does add confusion when the list of config params continues to grow, especially when multiple args are just the same struct fulfilling various single-method interfaces.

Copy link
Contributor Author

@ecwall ecwall 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 @knz)


-- commits line 13 at r1:

Previously, knz (Raphael 'kena' Poss) wrote…

nit: you do not need to include the full URL here, just Epic: CRDB-14522 is sufficient.

Done.


pkg/server/status.go line 1384 at r1 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

nit: period at end of comment.

Done.


pkg/server/serverpb/status.go line 84 at r1 (raw file):

Previously, dhartunian (David Hartunian) wrote…

@ecwall I agree in this case that we should avoid introducing a new interface. It looks like RegionsServer above and TenantStatusServer are used in the same contexts so I'd suggest either:

  • merging all 3 into TenantStatusServer to unify all the stuff tenants need from a Connector
    or
  • add your NodeLocality method to TenantStatusServer and put a TODO on RegionsServer to merge later

I don't see anything in particular gained from a separate interface here. It does add confusion when the list of config params continues to grow, especially when multiple args are just the same struct fulfilling various single-method interfaces.

Created a PR to merge the preexisting TenantStatusServer and RegionsServer here #92599. I'll rebase this PR on top of that after it merges.

@ecwall ecwall changed the title sql: add NodeLocalityServer to support crdb_internal.ranges{_no_leases} for secondary tenants sql: add TenantStatusServer.NodeLocality to support crdb_internal.ranges{_no_leases} for secondary tenants Nov 28, 2022
@ecwall ecwall requested a review from knz November 29, 2022 00:18
Copy link
Contributor

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


pkg/ccl/kvccl/kvtenantccl/connector.go line 421 at r4 (raw file):

		resp, err = c.Regions(ctx, req)
		return err
	}); err != nil {

nit:

err := c.withClient(...)
return resp, err

pkg/ccl/kvccl/kvtenantccl/connector.go line 436 at r4 (raw file):

		resp, err = c.NodeLocality(ctx, req)
		return err
	}); err != nil {

ditto

…ges{_no_leases} for secondary tenants

This PR adds a new node locality lookup KV admin function which is
used by crdb_internal.ranges{_no_leases} and SHOW RANGES to
work for secondary tenants.

Release note: None

Epic: CRDB-14522
@ecwall ecwall requested a review from rafiss November 29, 2022 16:11
@ecwall
Copy link
Contributor Author

ecwall commented Nov 29, 2022

bors r=knz

@craig craig bot merged commit edc6fda into cockroachdb:master Nov 29, 2022
@craig
Copy link
Contributor

craig bot commented Nov 29, 2022

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.

4 participants