Skip to content

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Oct 3, 2025

Previously, we adjusted the schema changer rules to ensure that
old secondary indexes are only dropped when the new secondary index is
usable. Unfortunately, one of the rules had an incorrect filter. To
address this, this patch fixes the filter to expect the new secondary
index, which will have the new flag. Additionally, the index recreation
logic for ALTER PRIMARY KEY was delaying when the new secondary indexes
could be made public.

Fixes: #154751

Release note: None

@fqazi fqazi added the backport-25.4.x Flags PRs that need to be backported to 25.4 label Oct 3, 2025
Copy link

blathers-crl bot commented Oct 3, 2025

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Oct 6, 2025

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.

@fqazi fqazi marked this pull request as ready for review October 6, 2025 15:28
@fqazi fqazi requested a review from a team as a code owner October 6, 2025 15:28
Previously, we adjusted the schema changer rules to ensure that
old secondary indexes are only dropped when the new secondary index is
usable. Unfortunately, one of the rules had an incorrect filter. To
address this, this patch fixes the filter to expect the new secondary
index, which will have the new flag. Additionally, the index recreation
logic for ALTER PRIMARY KEY was delaying when the new secondary indexes
could be made public.

Fixes: cockroachdb#154751

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! I am wondering if a dml injection would have caught this sooner? Maybe by scanning the secondary index at each stage of an ALTER PK.

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

Successfully merging this pull request may close these issues.

sql/schemachanger: fix incorrect filter for secondary index recreation during a pk swap
3 participants