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

schemachanger: remove discard named range fallback #135909

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

annrpom
Copy link
Contributor

@annrpom annrpom commented Nov 21, 2024

This patch removes the fallback to legacy schema changer
path we have for discarding named ranges. This includes
ensuring we block the ability to discard the system range.

Fixes: #133157

Epic: none
Release note: None

Copy link

blathers-crl bot commented Nov 21, 2024

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@annrpom annrpom force-pushed the dsc-discard-named-range branch 3 times, most recently from c04320c to 9eb50a4 Compare November 23, 2024 00:24
@annrpom annrpom marked this pull request as ready for review November 23, 2024 01:05
@annrpom annrpom requested review from a team as code owners November 23, 2024 01:05
@annrpom annrpom requested review from spilchen and removed request for a team November 25, 2024 16:25
Copy link
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Looks good. I just had a couple of questions.

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


pkg/sql/schemachanger/testdata/end_to_end/alter_named_range_configure_zone_discard/alter_named_range_configure_zone_discard.definition line 4 at r1 (raw file):

ALTER RANGE meta CONFIGURE ZONE USING num_replicas = 7;
ALTER RANGE meta CONFIGURE ZONE USING gc.ttlseconds = 10000;
ALTER RANGE meta CONFIGURE ZONE DISCARD;

Can we add a test that first discards the configuration and then applies updates in the same transaction? For example:

ALTER RANGE meta CONFIGURE ZONE DISCARD; 
ALTER RANGE meta CONFIGURE ZONE USING num_replicas = 7; 
ALTER RANGE meta CONFIGURE ZONE USING gc.ttlseconds = 10000;

I'm curious if we handle the operation ordering correctly, ensuring num_replicas and gc.ttlseconds are applied after the discard.


pkg/sql/schemachanger/scbuild/internal/scbuildstmt/configure_zone.go line 128 at r1 (raw file):

		id, found := zonepb.NamedZones[namedZone]
		if !found {
			return nil, fmt.Errorf("%q is not a built-in zone", string(zs.NamedZone))

Should this error have a proper pgcode set? I was able to find the error in the legacy schema changer that this mirrors.

Copy link
Contributor Author

@annrpom annrpom 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 @spilchen)


pkg/sql/schemachanger/scbuild/internal/scbuildstmt/configure_zone.go line 128 at r1 (raw file):

Previously, spilchen wrote…

Should this error have a proper pgcode set? I was able to find the error in the legacy schema changer that this mirrors.

done -- ah as in add a pgcode for this + the legacy schema changer? i can do that; i think 42602 might make the most sense (InvalidName)


pkg/sql/schemachanger/testdata/end_to_end/alter_named_range_configure_zone_discard/alter_named_range_configure_zone_discard.definition line 4 at r1 (raw file):

Previously, spilchen wrote…

Can we add a test that first discards the configuration and then applies updates in the same transaction? For example:

ALTER RANGE meta CONFIGURE ZONE DISCARD; 
ALTER RANGE meta CONFIGURE ZONE USING num_replicas = 7; 
ALTER RANGE meta CONFIGURE ZONE USING gc.ttlseconds = 10000;

I'm curious if we handle the operation ordering correctly, ensuring num_replicas and gc.ttlseconds are applied after the discard.

done -- added a logictest as that seemed better suited; wdyt?

This patch removes the fallback to legacy schema changer
path we have for discarding named ranges. This includes
ensuring we block the ability to discard the system range.

Fixes: cockroachdb#133157

Epic: none
Release note: None
Copy link
Contributor

@spilchen spilchen 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 3 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @annrpom)


pkg/sql/schemachanger/testdata/end_to_end/alter_named_range_configure_zone_discard/alter_named_range_configure_zone_discard.definition line 4 at r1 (raw file):

Previously, annrpom (annie pompa) wrote…

done -- added a logictest as that seemed better suited; wdyt?

Logic tests are much simpler! It seems mutations are applied in statement order, even when they involve different types of operations (e.g., discard vs. setting specific values).


pkg/sql/logictest/testdata/logic_test/zone_config line 450 at r2 (raw file):


statement ok
RESET use_declarative_schema_changer;

Is this safe to apply to the local legacy schema changer? We won't lose track of the fact that it's operating under the legacy schema changer, correct?

Copy link
Contributor Author

@annrpom annrpom 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! 1 of 0 LGTMs obtained (waiting on @spilchen)


pkg/sql/logictest/testdata/logic_test/zone_config line 450 at r2 (raw file):

Previously, spilchen wrote…

Is this safe to apply to the local legacy schema changer? We won't lose track of the fact that it's operating under the legacy schema changer, correct?

ooo good question! it looks like we will not lose track since that config overrides the cluster setting -- not the session variable (i also just confirmed this real quick by showing the session var value under the legacy config and it is confirmed off)

// We support disabling the declarative schema changer, so that no regressions
// occur in the legacy schema changer.
if cfg.DisableDeclarativeSchemaChanger {
if _, err := conn.Exec(
"SET CLUSTER SETTING sql.defaults.use_declarative_schema_changer='off'"); err != nil {
t.Fatal(err)
}
}

@annrpom
Copy link
Contributor Author

annrpom commented Nov 25, 2024

TFTR! ('-')7

bors r+

Copy link
Contributor

@spilchen spilchen 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! 1 of 0 LGTMs obtained


pkg/sql/logictest/testdata/logic_test/zone_config line 450 at r2 (raw file):

Previously, annrpom (annie pompa) wrote…

ooo good question! it looks like we will not lose track since that config overrides the cluster setting -- not the session variable (i also just confirmed this real quick by showing the session var value under the legacy config and it is confirmed off)

// We support disabling the declarative schema changer, so that no regressions
// occur in the legacy schema changer.
if cfg.DisableDeclarativeSchemaChanger {
if _, err := conn.Exec(
"SET CLUSTER SETTING sql.defaults.use_declarative_schema_changer='off'"); err != nil {
t.Fatal(err)
}
}

Thanks for confirming.

@craig craig bot merged commit bc04a81 into cockroachdb:master Nov 25, 2024
22 of 23 checks passed
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.

schemachanger: support configure zone discard for zone configs
3 participants