Skip to content

distsql: add plumbing for SQL pods to send RPCs to each other#76214

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rharding6373:distsql_multi_tenant
Feb 10, 2022
Merged

distsql: add plumbing for SQL pods to send RPCs to each other#76214
craig[bot] merged 1 commit intocockroachdb:masterfrom
rharding6373:distsql_multi_tenant

Conversation

@rharding6373
Copy link
Copy Markdown
Collaborator

This PR adds initial support for distributed flows in a multi-tenant cluster
with multiple pods. It adds a test that assigns flows to multiple pods
and executes them. In order to support communication between SQL pods in
a multi-tenant environment, this PR adds a new kind of connector that
can provide address resolution for SQL instances, and plumbs a node
dialer that uses this new connector through distsql. If distsql is not
in multi-tenant mode, the same node dialer is used whether SQL instances
are communicating with other SQL instances or KV, as before this change.

Release note: None

@rharding6373 rharding6373 requested a review from a team as a code owner February 8, 2022 02:07
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

@rharding6373 rharding6373 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 @cucaroach and @RaduBerinde)


pkg/sql/flowinfra/cluster_test.go, line 317 at r1 (raw file):

}

func TestTenantClusterFlow(t *testing.T) {

This has a lot of code duplication with TestClusterFlow, but it turns out TestTenantInterface and TestServerInterface aren't compatible and this makes refactoring them a bit painful. I could spend more time refactoring this if there are strong feelings about it at this stage (and no one suggests to move this into the kvtennantccl package to eliminate the include).

Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

CC @ajwerner

Nice work!!

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


pkg/ccl/kvccl/kvtenantccl/connector.go, line 603 at r1 (raw file):

}

type PodConnector struct {

[nit] needs a comment


pkg/ccl/kvccl/kvtenantccl/connector.go, line 615 at r1 (raw file):

}

func (p *PodConnector) GetNodeDescriptor(nodeID roachpb.NodeID) (*roachpb.NodeDescriptor, error) {

Instead of implementing this interface and passing it through kvtenant.AddressResolver, couldn't we directly implement a nodeDialer.AddressResolver? We wouldn't need to fake a NodeDescriptor.

I think nodeDialer.AddressResolver will eventually use a ServerID instead of NodeID (meaning that it can be either a SQLInstanceID or a NodeID depending on context).

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner 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 @cucaroach, @RaduBerinde, and @rharding6373)


pkg/ccl/kvccl/kvtenantccl/connector.go, line 615 at r1 (raw file):

Previously, RaduBerinde wrote…

Instead of implementing this interface and passing it through kvtenant.AddressResolver, couldn't we directly implement a nodeDialer.AddressResolver? We wouldn't need to fake a NodeDescriptor.

I think nodeDialer.AddressResolver will eventually use a ServerID instead of NodeID (meaning that it can be either a SQLInstanceID or a NodeID depending on context).

Copy link
Copy Markdown
Collaborator Author

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

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

TFTRs!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @cucaroach)


pkg/ccl/kvccl/kvtenantccl/connector.go, line 603 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] needs a comment

Removed.


pkg/ccl/kvccl/kvtenantccl/connector.go, line 615 at r1 (raw file):

Previously, ajwerner wrote…

Done.

Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde 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 @cucaroach and @rharding6373)


pkg/sql/flowinfra/cluster_test.go, line 317 at r1 (raw file):

Previously, rharding6373 (Rachael Harding) wrote…

This has a lot of code duplication with TestClusterFlow, but it turns out TestTenantInterface and TestServerInterface aren't compatible and this makes refactoring them a bit painful. I could spend more time refactoring this if there are strong feelings about it at this stage (and no one suggests to move this into the kvtennantccl package to eliminate the include).

I would leave it like this.


pkg/sql/flowinfra/cluster_test.go, line 15 at r2 (raw file):

import (
	"context"
	dbsql "database/sql"

[nit] we usually use gosql as the alias for this

Copy link
Copy Markdown
Collaborator Author

@rharding6373 rharding6373 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! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @cucaroach)


pkg/sql/flowinfra/cluster_test.go, line 15 at r2 (raw file):

Previously, RaduBerinde wrote…

[nit] we usually use gosql as the alias for this

Ah, I should have taken the linter seriously.

@rharding6373
Copy link
Copy Markdown
Collaborator Author

bors r+

This PR adds initial support for distributed flows in a multi-tenant cluster
with multiple pods. It adds a test that assigns flows to multiple pods
and executes them. In order to support communication between SQL pods in
a multi-tenant environment, this PR adds a new kind of connector that
can provide address resolution for SQL instances, and plumbs a node
dialer that uses this new connector through distsql. If distsql is not
in multi-tenant mode, the same node dialer is used whether SQL instances
are communicating with other SQL instances or KV, as before this change.

Release note: None
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 9, 2022

Canceled.

@rharding6373
Copy link
Copy Markdown
Collaborator Author

bors r-

@rharding6373
Copy link
Copy Markdown
Collaborator Author

bors r+

@craig craig bot merged commit 0fdf716 into cockroachdb:master Feb 10, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 10, 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