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: Fixed bug incorrect InvertedColumnKinds in the inverte… #138043

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

Dedej-Bergin
Copy link
Contributor

…d index

Previously the SHOW CREATE TABLE statement would lose index information. The fix now allows SHOW CREATE TABLE to show the correct information that can be repeatedly entered back into crdb to recreate the same table.

Fixes: #136410
Release note (bug fix): Previously SHOW CREATE TABLE was showing incorrect data with regards to inverted indexes. It now shows the correct data that can be repeatedly entered back into crdb to recreate the same table.

@Dedej-Bergin Dedej-Bergin requested a review from a team as a code owner December 27, 2024 17:34
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@Dedej-Bergin Dedej-Bergin added branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.3 Used to mark GA and release blockers, technical advisories, and bugs for 24.3 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 labels Dec 27, 2024
Copy link
Collaborator

@rafiss rafiss 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 @Dedej-Bergin)


pkg/sql/logictest/testdata/logic_test/show_create line 247 at r1 (raw file):


statement ok
CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING);

Logic tests have a hook that adds random column families to CREATE TABLE statements. That's why the SHOW CREATE output below has extra lines for FAMILY. To make the test stable, we need to add an explicit column family definition here. The test cases above this one do that too.

So this should be:

CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING, FAMILY f1 (id, x, y));

pkg/sql/logictest/testdata/logic_test/show_create line 248 at r1 (raw file):

statement ok
CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING);
CREATE INDEX ON roaches USING GIN (x, y gin_trgm_ops);

I ran this test with your change in pkg/sql/schemachanger/scexec/scmutationexec/index.go reverted, and it still passed

i think it's because the statements are sent as a batch, which causes them all the run in one transaction, which means the legacy schema changer will be used. so we need to separate them:

statement ok
CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING, FAMILY f1 (id, x, y));

statement ok
CREATE INDEX ON roaches USING GIN (x, y gin_trgm_ops);

Copy link
Collaborator

@rafiss rafiss 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 @Dedej-Bergin)


pkg/sql/logictest/testdata/logic_test/show_create line 248 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

I ran this test with your change in pkg/sql/schemachanger/scexec/scmutationexec/index.go reverted, and it still passed

i think it's because the statements are sent as a batch, which causes them all the run in one transaction, which means the legacy schema changer will be used. so we need to separate them:

statement ok
CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING, FAMILY f1 (id, x, y));

statement ok
CREATE INDEX ON roaches USING GIN (x, y gin_trgm_ops);

As a more general tip, whenever you make a bug fix and add a test for it, you should always make sure the test fails without your bug fix.

…d index

Previously the `SHOW CREATE TABLE` statement would
lose index information. The fix now allows `SHOW CREATE TABLE`
to show the correct information that can be repeatedly entered back
into crdb to recreate the same table.

Fixes: cockroachdb#136410
Release note (bug fix): Previously `SHOW CREATE TABLE` was showing
incorrect data with regards to inverted indexes.  It now shows the
correct data that can be repeatedly entered back into crdb to recreate
the same table.
Copy link
Contributor Author

@Dedej-Bergin Dedej-Bergin 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 @rafiss)


pkg/sql/logictest/testdata/logic_test/show_create line 247 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

Logic tests have a hook that adds random column families to CREATE TABLE statements. That's why the SHOW CREATE output below has extra lines for FAMILY. To make the test stable, we need to add an explicit column family definition here. The test cases above this one do that too.

So this should be:

CREATE TABLE roaches (id UUID PRIMARY KEY, x STRING, y STRING, FAMILY f1 (id, x, y));

Thanks Rafi! Just made this change.


pkg/sql/logictest/testdata/logic_test/show_create line 248 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

As a more general tip, whenever you make a bug fix and add a test for it, you should always make sure the test fails without your bug fix.

Thanks Rafi! I went ahead and made this change, thanks for the tip!

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Dedej-Bergin)

@Dedej-Bergin
Copy link
Contributor Author

TFTR!

bors r+

@craig craig bot merged commit 1fe09ec into cockroachdb:master Dec 30, 2024
22 checks passed
@rafiss rafiss added backport-23.2.x Flags PRs that need to be backported to 23.2. backport-24.1.x Flags PRs that need to be backported to 24.1. backport-24.2.x Flags PRs that need to be backported to 24.2 backport-24.3.x Flags PRs that need to be backported to 24.3 and removed branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 branch-release-24.3 Used to mark GA and release blockers, technical advisories, and bugs for 24.3 labels Dec 30, 2024
@rafiss
Copy link
Collaborator

rafiss commented Dec 30, 2024

blathers backport 24.3 24.2 24.1 23.2

Copy link

blathers-crl bot commented Dec 30, 2024

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from c902275 to blathers/backport-release-24.1-138043: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 24.1 failed. See errors above.


error creating merge commit from c902275 to blathers/backport-release-23.2-138043: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.2 failed. See errors above.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.2.x Flags PRs that need to be backported to 23.2. backport-24.1.x Flags PRs that need to be backported to 24.1. backport-24.2.x Flags PRs that need to be backported to 24.2 backport-24.3.x Flags PRs that need to be backported to 24.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

schemachanger: incorrect InvertedColumnKinds in the inverted index
3 participants