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, featureflag: add schema change feature flag #57040

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

angelapwen
Copy link

@angelapwen angelapwen commented Nov 24, 2020

The following features have been tested and act as expected:

  • ALTER DATABASE OWNER
  • ALTER DATABASE ADD REGION
  • ALTER DATABASE DROP REGION
  • ALTER DATABASE SURVIVE
  • ALTER TABLE REGIONAL AFFINITY
  • ALTER TABLE SET SCHEMA
  • ALTER SCHEMA
  • ALTER TYPE
  • ALTER SEQUENCE RENAME
  • ALTER SEQUENCE SET SCHEMA
  • CREATE DATABASE
  • CREATE INDEX
  • CREATE SCHEMA
  • CREATE TABLE
  • CREATE TYPE
  • CREATE VIEW
  • CREATE SEQUENCE
  • DROP DATABASE
  • DROP INDEX
  • DROP TABLE
  • DROP VIEW
  • DROP SEQUENCE
  • DROP TYPE
  • DROP SCHEMA
  • REASSIGN OWNED BY
  • DROP OWNED BY
  • RENAME DATABASE
  • REPARENT DATABASE
  • RENAME INDEX
  • RENAME TABLE
  • RENAME COLUMN
  • COMMENT ON COLUMN
  • COMMENT ON DATABASE
  • COMMENT ON INDEX
  • COMMENT ON TABLE
  • ALTER INDEX CONFIGURE ZONE
  • ALTER TABLE CONFIGURE ZONE

See #51643 for background.

ANALYZE/CREATE STATISTICS will not be considered a schema change and were added in a separate PR, #57076
The SPLIT/UNSPLIT features will also be resolved in a separate PR, as the execution path is different from the schema changes addressed in this PR.

---Commit message---

This change adds a feature flag via cluster setting for all
designated features that perform schema changes or DDLs. The
feature is being introduced to address a Cockroach Cloud SRE use
case: needing to disable certain categories of features, such as
schema changes, in case of cluster failure.

Release note (sql change): Adds a feature flag via cluster
setting for all schema change-related features. If a user attempts
to use these features while they are disabled, an error indicating
that the database administrator has disabled the feature is
surfaced.

Example usage for the database administrator:
SET CLUSTER SETTING feature.schemachange.enabled = FALSE;
SET CLUSTER SETTING feature.schemachange.enabled = TRUE;

@angelapwen angelapwen added the do-not-merge bors won't merge a PR with this label. label Nov 24, 2020
@angelapwen angelapwen requested review from otan and a team November 24, 2020 00:30
@angelapwen angelapwen self-assigned this Nov 24, 2020
@angelapwen angelapwen requested review from pbardea and removed request for a team November 24, 2020 00:30
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

this is awesome! two small changes requested.

Reviewed 41 of 41 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @angelapwen and @pbardea)


pkg/sql/alter_database.go, line 36 at r1 (raw file):

	if err := featureflag.CheckEnabled(featureSchemaChangeEnabled,
		&p.ExecCfg().Settings.SV,
		"ALTER DATABASE is part of the schema change category, which",

if we're including this message for all schema changes, might be worth adding a helper function so you only put ALTER DATABASE here. maybe put the function in this package so the featureflag package is schema change agnostic.


pkg/sql/create_stats.go, line 55 at r1 (raw file):

	if err := featureflag.CheckEnabled(featureSchemaChangeEnabled,
		&p.ExecCfg().Settings.SV,
		"ANALYZE/CREATE STATS is part of the schema change category, which"); err != nil {

i think these aren't schema changes -- might be worth creating a separate PR and put this as part of the CREATE_STATS or ANALYZE flag.


pkg/sql/schema_change_cluster_setting.go, line 24 at r1 (raw file):

// package?
var featureSchemaChangeEnabled = settings.RegisterPublicBoolSetting(
	"feature.schemachange.enabled",

can we make this schema_change since it is two words?

Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

oops, premature accept.

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

Copy link
Author

@angelapwen angelapwen 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 @otan and @pbardea)


pkg/sql/alter_database.go, line 36 at r1 (raw file):

Previously, otan (Oliver Tan) wrote…

if we're including this message for all schema changes, might be worth adding a helper function so you only put ALTER DATABASE here. maybe put the function in this package so the featureflag package is schema change agnostic.

Yeah, that makes sense. I'll put it under the schema_change_cluster_setting package where I register the settings.


pkg/sql/create_stats.go, line 55 at r1 (raw file):

Previously, otan (Oliver Tan) wrote…

i think these aren't schema changes -- might be worth creating a separate PR and put this as part of the CREATE_STATS or ANALYZE flag.

Ah alright!


pkg/sql/schema_change_cluster_setting.go, line 24 at r1 (raw file):

Previously, otan (Oliver Tan) wrote…

can we make this schema_change since it is two words?

Yes!

@angelapwen angelapwen force-pushed the add-schema-change-feature-flag branch from b71c2db to 93fd5af Compare November 24, 2020 01:34
@blathers-crl blathers-crl bot requested a review from otan November 24, 2020 01:34
@angelapwen angelapwen force-pushed the add-schema-change-feature-flag branch from 93fd5af to d1bf094 Compare November 24, 2020 01:43
@pbardea pbardea removed their request for review November 24, 2020 20:40
@angelapwen angelapwen force-pushed the add-schema-change-feature-flag branch 6 times, most recently from 11ddecf to a402346 Compare November 25, 2020 00:40
@angelapwen angelapwen changed the title sql, featureflag: [WIP] add schema change feature flag sql, featureflag: add schema change feature flag Nov 25, 2020
@otan otan removed the do-not-merge bors won't merge a PR with this label. label Nov 25, 2020
Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

Looks like two small failures left.

go test ./pkg/sql/pgwire -run TestPGTest/notice -rewrite to fix the notice one!

Reviewed 42 of 42 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan)

This change adds a feature flag via cluster setting for all
designated features that perform schema changes or DDLs. The
feature is being introduced to address a Cockroach Cloud SRE use
case: needing to disable certain categories of features, such as
schema changes, in case of cluster failure.

Release note (sql change): Adds a feature flag via cluster
setting for all schema change-related features. If a user attempts
to use these features while they are disabled, an error indicating
that the database administrator has disabled the feature is
surfaced.

Example usage for the database administrator:
SET CLUSTER SETTING feature.schemachange.enabled = FALSE;
SET CLUSTER SETTING feature.schemachange.enabled = TRUE;
@angelapwen angelapwen force-pushed the add-schema-change-feature-flag branch from a402346 to 1166346 Compare November 25, 2020 02:32
@blathers-crl blathers-crl bot requested a review from otan November 25, 2020 02:32
Copy link
Author

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Thanks! I think I've addressed the two failures just now.

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

@angelapwen
Copy link
Author

bors r=otan

Copy link
Contributor

@otan otan 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 @otan)

@craig
Copy link
Contributor

craig bot commented Nov 25, 2020

Build failed:

@angelapwen
Copy link
Author

Flaky roachtest, giving this another go 🙏

bors r=otan

@craig
Copy link
Contributor

craig bot commented Nov 25, 2020

Build succeeded:

@craig craig bot merged commit 82ae151 into cockroachdb:master Nov 25, 2020
angelapwen pushed a commit to angelapwen/cockroach that referenced this pull request Nov 25, 2020
Release note (sql change): This is an empty commit meant to correct
a mistake in a merged release note in cockroachdb#57040. The original release
note indicates that a database administrator should toggle this
feature flag on and off using
SET CLUSTER SETTING feature.schemachange.enabled, but there
should be a '_' character so that the cluster setting would be:
SET CLUSTER SETTING feature.schema_change.enabled.

Below is the full original release note, with the typo fixed.

Release note (sql change): Adds a feature flag via cluster setting
for all schema change-related features. If a user attempts
to use these features while they are disabled, an error indicating
that the database administrator has disabled the feature is
surfaced.

Example usage for the database administrator:
SET CLUSTER SETTING feature.schema_change.enabled = FALSE;
SET CLUSTER SETTING feature.schema_change.enabled = TRUE;
craig bot pushed a commit that referenced this pull request Nov 26, 2020
57143: docs: edit release note for schema change feature flag r=otan a=angelapwen

Release note (sql change): This is an empty commit meant to correct
a mistake in a merged release note in #57040. The original release
note indicates that a database administrator should toggle this
feature flag on and off using
SET CLUSTER SETTING feature.schemachange.enabled, but there
should be a '_' character so that the cluster setting would be:
SET CLUSTER SETTING feature.schema_change.enabled.

Below is the full original release note, with the typo fixed.

Release note (sql change): Adds a feature flag via cluster setting
for all schema change-related features. If a user attempts
to use these features while they are disabled, an error indicating
that the database administrator has disabled the feature is
surfaced.

Example usage for the database administrator:
SET CLUSTER SETTING feature.schema_change.enabled = FALSE;
SET CLUSTER SETTING feature.schema_change.enabled = TRUE;

Co-authored-by: angelapwen <[email protected]>
@angelapwen angelapwen deleted the add-schema-change-feature-flag branch February 5, 2021 00:16
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