Skip to content

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Aug 27, 2025

Backport 1/1 commits from #151423.

/cc @cockroachdb/release


A bug was recently discovered that causes UPDATE and DELETE operations to fail on a table while it is being converted to REGIONAL BY ROW.

To protect against this, this patch blocks the ALTER TABLE LOCALiTY statement if the sql_safe_updates flag is on. The error hint provides a workaround to safely convert the locality.

fixes #150945
Release note (sql change): When sql_safe_updates is enabled, the ALTER TABLE LOCALITY statement will now be blocked when trying to convert an existing table to REGIONAL BY ROW, unless a region column has already been added to the table. This protects against undesired behavior that caused UPDATE or DELETE queries to fail against the table while the locality change is in progress.

Release justification: Add a safety check for an operation that can cause DML to stop working, with instructions on how to proceed safely.

A bug was recently discovered that causes UPDATE and DELETE operations
to fail on a table while it is being converted to REGIONAL BY ROW.

To protect against this, this patch blocks the ALTER TABLE LOCALiTY
statement if the sql_safe_updates flag is on. The error hint provides a
workaround to safely convert the locality.

Release note (sql change): When sql_safe_updates is enabled, the ALTER
TABLE LOCALITY statement will now be blocked when trying to convert an
existing table to REGIONAL BY ROW, unless a region column has already
been added to the table. This protects against undesired behavior that
caused UPDATE or DELETE queries to fail against the table while the
locality change is in progress.
@rafiss rafiss requested a review from a team as a code owner August 27, 2025 16:42
Copy link

blathers-crl bot commented Aug 27, 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 27, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Aug 27, 2025

✅ PR #152600 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]
Feature flag detected: Yes
Backward compatible: true
Explanation: The pull request is compliant with the backport policy for a number of reasons. Firstly, the PR includes a 'Release justification' which effectively states that the change adds a safety check to prevent DML failures during REGIONAL BY ROW conversions when sql_safe_updates is enabled, thereby addressing a significant bug that could affect database stability and correctness. This aligns with the critical bug criteria, specifically those related to stability and potentially incorrect results. Secondly, the PR is backward compatible as it doesn't remove any version gates or existing functionality, instead it adds conditions to manage specific alterations more safely. The actual change in 'pkg/sql/alter_table_locality.go' directly implements this safety feature effectively gating the operation behind existing session settings, thus satisfying feature flag requirements inherently. Finally, all changes including those in test files are appropriate, targeting correct functionality coverage and ensuring the feature's impact is well-tested without affecting non-test environments.

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

@rafiss rafiss merged commit d506978 into cockroachdb:release-25.2 Aug 27, 2025
16 checks passed
@rafiss rafiss deleted the backport25.2-151423 branch August 30, 2025 17:06
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 T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) v25.2.6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants