Skip to content

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Aug 22, 2025

Backport 1/1 commits from #151947 on behalf of @fqazi.


Previously, when a default expression was cleaned up the sequence ownerships would be incorrectly cleaned up. This meant when we added support for setting default expressions in the declarative schema changer, any updates could wipe out sequence ownership information. To address this, this patch removes the incorrect clean up logic.

Fixes: #151925

Release note (bug fix): Updating column default expressions would incorrectly remove sequence ownerships for the affected column.


Release justification: low risk bug fix to prevent leaving an orphaned sequence in an invalid state.

Previously, when a default expression was cleaned up the sequence
ownerships would be incorrectly cleaned up. This meant when we added
support for setting default expressions in the declarative schema
changer, any updates could wipe out sequence ownership information. To
address this, this patch removes the incorrect clean up logic.

Fixes: cockroachdb#151925

Release note (bug fix): Updating column default expressions would
incorrectly remove sequence ownerships for the affected column.
@fqazi fqazi requested a review from a team as a code owner August 22, 2025 00:17
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Aug 22, 2025
@blathers-crl blathers-crl bot requested a review from rafiss August 22, 2025 00:17
Copy link

blathers-crl bot commented Aug 22, 2025

Thanks for opening a backport.

Before merging, please confirm that it falls into one of the following categories (select one):

  • Non-production code changes. Includes test-only changes, build system changes, etc.
  • Fixes for serious issues. Defined in the policy as correctness, stability, or security issues, data corruption/loss, significant performance regressions, breaking working and widely used functionality, or an inability to detect and debug production issues.
  • Other approved changes. These changes must be gated behind a disabled-by-default feature flag unless there is a strong justification not to.

Add a brief release justification to the PR description explaining your selection.

Also, confirm that the change does not break backward compatibility and complies with all aspects of the backport policy.

All backports must be reviewed by the TL and EM for the owning area.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Aug 22, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Aug 22, 2025

✅ PR #152312 is compliant with backport policy

Confidence: high
Critical bug criteria met: [Stability or security issues Bugs that can cause the DB to return incorrect results or result in suboptimal performance]
Backward compatible: true
Explanation: The pull request addresses a critical bug related to incorrect cleanup of sequence ownerships in the database, potentially leaving orphaned sequences in an invalid state. This correction is important for ensuring the database maintains proper integrity and functionality, thus fulfilling the critical bug criteria defined in the backport policy. The file pkg/sql/schemachanger/scexec/scmutationexec/helpers.go was modified to remove the incorrect cleanup logic, which directly pertains to protecting sequence ownership during updates to column default expressions. Additionally, changes made to pkg/sql/logictest/testdata/logic_test/sequences are purely within the testing suite which confirms the bug fix without affecting production code directly. The pull request also offers a valid 'Release justification: low risk bug fix to prevent leaving an orphaned sequence in an invalid state,' which aptly covers the intentions and impact of the fix.

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

@rafiss rafiss merged commit 26f0cff into cockroachdb:release-24.1 Aug 22, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) v24.1.24
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants