-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
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
|
I'd write a logic test. You can express
interleaved logic test file.
|
There was a problem hiding this 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: 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)
There was a problem hiding this 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: complete! 0 of 0 LGTMs obtained (waiting on @postamar and @rafiss)
There was a problem hiding this 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: complete! 0 of 0 LGTMs obtained (waiting on @postamar and @rafiss)
There was a problem hiding this 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: 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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
Looks like I forgot some test cases in |
What are the errors? One trick is to use the builder docker container: |
There was a problem hiding this 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: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @rafiss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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.
There was a problem hiding this 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: 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 thatMakeURL
puts the version prefix in the url string and my understanding is this will break CI tests when building a real version: assertions onSee: https://go.crdb.dev/issue-v/52009/dev
(in pkg/sql) orSee: https://go.crdb.dev/issue-v/52009/v999.0
(in pkg/cli) will fail.
Perhaps for the SQL logic tests I could expandstatement
to assert onnotice
instead of justok
orerror
, to do assertions on notices in a similar way tostatement 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 18 of 18 files at r3.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner, @postamar, and @rafiss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @ajwerner, @jordanlewis, @postamar, and @rafiss)
bors r+ |
Build succeeded: |
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.