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: gate tenant's multi-region abstraction usage behind cluster setting #79536

Merged
merged 2 commits into from
Apr 16, 2022

Conversation

arulajmani
Copy link
Collaborator

@arulajmani arulajmani commented Apr 6, 2022

This patch introduces a tenant read-only cluster setting called
sql.multi_region.allow_abstractions_for_secondary_tenants.enabled
which allows the operator to control if secondary tenants can make use
of multi-region abstractions. It defaults to false.

This setting is checked against when creating new MR databases or
altering existing ones to make use of MR features (by setting the
primary region). It has nothing to do with MR databases that may have
been created previously which could happen if this setting was ever
flipped to true by the operator.

This setting doesn't effect the system tenant. It also takes precedence
over sql.defaults.primary_region, which is tenant writeable.

Release note (sql change): introduces new cluster setting which allows
the operator to control if a secondary tenant can make use of MR
abstractions. The setting is called
sql.multi_region.allow_abstractions_for_secondary_tenants.enabled.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

// directive.
type tenantClusterSettingOverrideMultiTenantMultiRegionAbstractionsAllowed struct{}

var _ tenantClusterSettingOverrideOpt = &tenantClusterSettingOverrideMultiTenantMultiRegionAbstractionsAllowed{}
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a lot of words 😛

@@ -361,6 +361,23 @@ var DefaultPrimaryRegion = settings.RegisterStringSetting(
"",
).WithPublic()

const secondaryTenantsMultiRegionAbstractionsEnabledSettingName = "sql.multi_region.abstractions.enabled"
Copy link
Contributor

Choose a reason for hiding this comment

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

Include "tenant" in the setting name somewhere?

Copy link
Collaborator Author

@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.

Dismissed @irfansharif from a discussion.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm and @irfansharif)


pkg/sql/descriptor.go, line 364 at r1 (raw file):

Previously, irfansharif (irfan sharif) wrote…

Include "tenant" in the setting name somewhere?

Good point, done.


pkg/sql/logictest/logic.go, line 2158 at r1 (raw file):

Previously, irfansharif (irfan sharif) wrote…

That's a lot of words 😛

🚀 🚀

This patch introduces a tenant read-only cluster setting called
`sql.multi_region.allow_abstractions_for_secondary_tenants.enabled`
which allows the operator to control if secondary tenants can make use
of multi-region abstractions. It defaults to false.

This setting is checked against when creating new MR databases or
altering existing ones to make use of MR features (by setting the
primary region). It has nothing to do with MR databases that may have
been created previously which could happen if this setting was ever
flipped to true by the operator.

This setting doesn't effect the system tenant. It also takes precedence
over `sql.defaults.primary_region`, which is tenant writeable.

Release note (sql change): introduces new cluster setting which allows
the operator to control if a secondary tenant can make use of MR
abstractions. The setting is called
`sql.multi_region.allow_abstractions_for_secondary_tenants.enabled`.
Copy link
Collaborator

@ajstorm ajstorm left a comment

Choose a reason for hiding this comment

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

Skimmed this and it seems reasonable to me. One question: do we want to prevent restoring MR-enabled databases to clusters with this setting set to false? If we don't it seems to be a pretty easy back-door to walk through.

Reviewed 1 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @arulajmani, and @irfansharif)


pkg/sql/descriptor.go, line 403 at r2 (raw file):

		return nil, errors.WithHint(pgerror.Newf(
			pgcode.InvalidDatabaseDefinition,
			"setting %s disallows use of multi-region abstractions",

Nit: If this is going to be seen by Serverless users, is this the right error here? Maybe something like "multi-region abstractions have been disabled on this cluster".

@ajstorm ajstorm self-requested a review April 7, 2022 17:28
@arulajmani arulajmani requested review from a team and shermanCRL and removed request for a team April 11, 2022 18:09
Copy link
Collaborator Author

@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.

Skimmed this and it seems reasonable to me. One question: do we want to prevent restoring MR-enabled databases to clusters with this setting set to false? If we don't it seems to be a pretty easy back-door to walk through.

That's a good catch. I tacked on a second commit here which checks the value of this cluster setting when a secondary tenant tries to restore a MR database. @adityamaru would you mind giving the second commit a quick look?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @arulajmani, @irfansharif, and @shermanCRL)

@@ -1949,6 +1954,32 @@ func renameTargetDatabaseDescriptor(
return nil
}

// ensureMultiRegionDatabaseRestoreIsAllowed
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: comment is truncated

This patch makes it such that RESTORE now consults the
`sql.multi_region.allow_abstractions_for_secondary_tenants.enabled`
cluster setting when a multi-region database is restored by a
secondary tenant. The system tenant remains unaffected. Additonally,
similar to how cluster setting above overrides the default primary
region on database creation, the same philosophy holds for restore
as well.

Release note (backup change): The
`sql.multi_region.allow_abstractions_for_secondary_tenants.enabled`
cluster setting is consulted when a secondary tenant tries to restore
a multi-region database now.
Copy link
Collaborator Author

@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.

TFTRs!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm, @arulajmani, @irfansharif, and @shermanCRL)


pkg/ccl/backupccl/restore_planning.go, line 1957 at r4 (raw file):

Previously, adityamaru (Aditya Maru) wrote…

nit: comment is truncated

Done.

@craig
Copy link
Contributor

craig bot commented Apr 15, 2022

Build failed:

@arulajmani
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 16, 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.

5 participants