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 notice for interleaved tables #56874

Merged
merged 1 commit into from
Nov 23, 2020
Merged

Conversation

postamar
Copy link
Contributor

This patch adds a deprecation notice when the user attempts to create an
interleaved table by executing a CREATE TABLE ... INTERLEAVE IN PARENT
statement.

Fixes #56579.

Release note (sql change): Added deprecation notice to CREATE TABLE ...
INTERLEAVE IN PARENT statements.

@postamar postamar requested a review from rafiss November 18, 2020 23:28
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@postamar
Copy link
Contributor Author

Did I do this right? At this point I'm wondering if it's possible to test against notices. I saw it show up when I ran cockroach demo and I'm not sure whether that's good enough:

[email protected]:26257/movr> CREATE TABLE public.barf ( id UUID NOT NULL, city VARCHAR NOT NULL, PRIMARY KEY (city, id) ) INTERLEAVE IN PARENT users (city, id);
NOTICE: interleaved tables are deprecated
CREATE TABLE

Time: 44ms total (execution 20ms / network 24ms)

@ajwerner
Copy link
Contributor

I'd write a logic test. You can express NOTICE expectations in them with the noticetrace option. See

. Probably this belongs in the interleaved logic test file.

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

Nice!

You should add tests to a "logic test".

Logic tests are data driven tests that live in files in pkg/sql/logictest/testdata/logic_test. Grep that directory for noticetrace, and you'll see a bunch of tests that assert notices.

You can run an individual logic test file like this:

make testbaselogic FILES=yourfile

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


pkg/sql/create_table.go, line 225 at r1 (raw file):

		params.p.BufferClientNotice(
			params.ctx,
			pgnotice.Newf("interleaved tables are deprecated"),

I think we should say:

interleaved tables will be deprecated in 21.1, and removed in 21.2

And, in a hint (see errors.WithHintf), say:

see https://github.com/cockroachdb/cockroach/issues/52009 for more details.

It's possible that we want to bikeshed this wording a bit (cc @vy-ton)

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

Oops, sorry for the double feedback from myself and Andrew, saying the same thing in both messages.

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

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

There are a few more places we need to add this notice to, as well.

  • ALTER PRIMARY KEY, which can make a table interleaved
  • CREATE INDEX, which can make an index interleaved

Example:

alter table a alter primary key using columns (a, b) interleave in parent(a)
create index foo on b(a) interleave in parent a(a)

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

Copy link
Contributor Author

@postamar postamar left a comment

Choose a reason for hiding this comment

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

(edit: sorry still getting familiar with Reviewable)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @rafiss, and @vy-ton)


pkg/sql/create_table.go, line 225 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

I think we should say:

interleaved tables will be deprecated in 21.1, and removed in 21.2

And, in a hint (see errors.WithHintf), say:

see https://github.com/cockroachdb/cockroach/issues/52009 for more details.

It's possible that we want to bikeshed this wording a bit (cc @vy-ton)

I took the liberty of rewording it to "interleaved tables and indexes will..." after discussion with @ajwerner

Copy link
Contributor

@vy-ton vy-ton 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 @ajwerner and @rafiss)


pkg/sql/create_table.go, line 225 at r1 (raw file):

will be deprecated in 21.1

Are we backporting the notice to 20.2? If so, I would prefer interleaved tables and indexes are deprecated in 20.2 and will be removed in 21.2

@postamar
Copy link
Contributor Author

postamar commented Nov 20, 2020

Looks like I forgot some test cases in pkg/cli, that was careless of me. For some reason I was unable to run those locally with make test PKG=./pkg/cli, I keep getting seemingly unrelated version errors, is this expected?

@ajwerner
Copy link
Contributor

What are the errors? One trick is to use the builder docker container: ./build/builder.sh make test .... That thing is handy.

Copy link
Contributor Author

@postamar postamar left a comment

Choose a reason for hiding this comment

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

They were errors which I wasn't able to reproduce after trying the docker build, the conclusion I'm taking from this is I need to better understand the build process, pronto. In any case I was able to run the tests locally today.

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

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r2 (raw file):

			errors.WithHint(
				pgnotice.Newf("interleaved tables and indexes are deprecated in 20.2 and will be removed in 21.2"),
				"See https://github.com/cockroachdb/cockroach/issues/52009 for more details.",

Can you please use the facility unimplemented.MakeURL()
(you may want to move that function from package "unimplemented" to something with a more generic name)

As we want to have proper telemetry on URL usage


pkg/sql/create_index.go, line 400 at r2 (raw file):

			errors.WithHint(
				pgnotice.Newf("interleaved tables and indexes are deprecated in 20.2 and will be removed in 21.2"),
				"See https://github.com/cockroachdb/cockroach/issues/52009 for more details.",

ditto


pkg/sql/create_table.go, line 227 at r2 (raw file):

			errors.WithHint(
				pgnotice.Newf("interleaved tables and indexes are deprecated in 20.2 and will be removed in 21.2"),
				"See https://github.com/cockroachdb/cockroach/issues/52009 for more details.",

ditto

Copy link
Contributor Author

@postamar postamar 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 @ajwerner, @knz, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r2 (raw file):

Previously, knz (kena) wrote…

Can you please use the facility unimplemented.MakeURL()
(you may want to move that function from package "unimplemented" to something with a more generic name)

As we want to have proper telemetry on URL usage

I looked into this and found out about errors.WithIssueLink which seems the way to go. Anyway I noticed that MakeURL puts the version prefix in the url string and my understanding is this will break CI tests when building a real version: assertions on See: https://go.crdb.dev/issue-v/52009/dev (in pkg/sql) or See: https://go.crdb.dev/issue-v/52009/v999.0 (in pkg/cli) will fail.
Perhaps for the SQL logic tests I could expand statement to assert on notice instead of just ok or error, to do assertions on notices in a similar way to statement error which seems to cope well in this case (see https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/logictest/testdata/logic_test/temp_table#L4 ) but I'm not sure how to do it right for CLI tests. I'm looking into it.

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.

Reviewed 5 of 5 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r2 (raw file):

Previously, postamar (Marius Posta) wrote…

I looked into this and found out about errors.WithIssueLink which seems the way to go. Anyway I noticed that MakeURL puts the version prefix in the url string and my understanding is this will break CI tests when building a real version: assertions on See: https://go.crdb.dev/issue-v/52009/dev (in pkg/sql) or See: https://go.crdb.dev/issue-v/52009/v999.0 (in pkg/cli) will fail.
Perhaps for the SQL logic tests I could expand statement to assert on notice instead of just ok or error, to do assertions on notices in a similar way to statement error which seems to cope well in this case (see https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/logictest/testdata/logic_test/temp_table#L4 ) but I'm not sure how to do it right for CLI tests. I'm looking into it.

So yes you found that our automated logic tests are not able to deal with this properly. This is a limitation in the test framework, not an indication that you should do the implementation differently (my idiom for this is "don't let the tail wag the dog")

These special URLs generated by MakeURL achieve multiple things:

  • they tell our product team when people click the links.
  • they tell our product team which version the user is encountering the link in.
  • they enable us to redirect the URLs to something else than github if/when we migrate from github issues to something else.

Overall we're moving away from raw github URLs. That's what I'm pointing out here.

Copy link
Contributor Author

@postamar postamar 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 @ajwerner, @knz, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r2 (raw file):

Previously, knz (kena) wrote…

So yes you found that our automated logic tests are not able to deal with this properly. This is a limitation in the test framework, not an indication that you should do the implementation differently (my idiom for this is "don't let the tail wag the dog")

These special URLs generated by MakeURL achieve multiple things:

  • they tell our product team when people click the links.
  • they tell our product team which version the user is encountering the link in.
  • they enable us to redirect the URLs to something else than github if/when we migrate from github issues to something else.

Overall we're moving away from raw github URLs. That's what I'm pointing out here.

Thanks for confirming and for explaining.

I published a new revision which extends the test framework in a way I'm hoping you'll all find reasonable and not too out of scope. This does place a higher burden on the reviewers though. FWIW I cursorily checked the new feature's correctness by falsifying the expected notice patterns and making sure the assertions correspondingly failed.

I found a workaround for the pkg/cli tests, checking for the notice there is redundant anyway.

This patch adds a deprecation notice on execution of a statement
containing an INTERLEAVE IN PARENT clause. These are:
 - CREATE TABLE ... INTERLEAVE IN PARENT ...
 - ALTER TABLE ... ALTER PRIMARY KEY ... INTERLEAVE IN PARENT ...
 - CREATE INDEX ... INTERLEAVE IN PARENT ...

Previously, we weren't able to test notices in sql logic tests by
asserting against regexps, only against plain text using `query T
noticetrace`. This made us unable to test deprecation notices
featuring issue links, which include build version info. This commit
addresses that by adding support for `statement notice <regexp>` in
the logic test framework.

Fixes cockroachdb#56579.

Release note (sql change): Added deprecation notice to statements
containing INTERLEAVE IN PARENT clause.
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: very nice 💯

Reviewed 18 of 18 files at r3.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner, @postamar, and @rafiss)

Copy link
Contributor

@vy-ton vy-ton 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 @ajwerner, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r3 (raw file):

			ctx,
			errors.WithIssueLink(
				pgnotice.Newf("interleaved tables and indexes are deprecated in 20.2 and will be removed in 21.2"),

@jordanlewis @lucy-zhang Are we ok with this deprecation being backported to 20.2?

Copy link
Contributor

@thoszhang thoszhang 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 @ajwerner, @jordanlewis, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r3 (raw file):

Previously, vy-ton (Vy Ton) wrote…

@jordanlewis @lucy-zhang Are we ok with this deprecation being backported to 20.2?

We're documenting the feature as deprecated in 20.2, right? I think that's fine.

Copy link
Contributor

@vy-ton vy-ton 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 @ajwerner, @jordanlewis, @postamar, and @rafiss)


pkg/sql/alter_primary_key.go, line 38 at r3 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

We're documenting the feature as deprecated in 20.2, right? I think that's fine.

Yes I filed https://github.com/cockroachdb/docs/issues/8891to be done after this notice is added

@postamar postamar requested a review from jordanlewis November 23, 2020 19:02
Copy link
Member

@jordanlewis jordanlewis 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! 2 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, @postamar, and @rafiss)

@postamar
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 23, 2020

Build succeeded:

@craig craig bot merged commit c27ae46 into cockroachdb:master Nov 23, 2020
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.

sql: add notice for interleaved tables
7 participants