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:48
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 #152603 is compliant with backport policy

Confidence: high
Critical bug criteria met: [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 deals with changing the behavior of the ALTER TABLE LOCALITY command to enhance safety during database operations, specifically when the sql_safe_updates setting is enabled. This change acts as a safeguard for potential issues during the update or delete operations on tables being altered to REGIONAL BY ROW, addressing reported problems with undesired DML behavior. The change is made compliant with the backport policy as described in the PR's release justification, which specifies it adds a safety check to prevent operational disruptions. There are also tests included to validate this behavior in the non-production files which are exempt from the backport requirements. The feature itself, governed by the sql_safe_updates setting, acts effectively as a feature flag since the added restriction only applies when sql_safe_updates is active. Consequently, this mitigates the behavior change impact by allowing users to opt-out. The existing functionality for users with sql_safe_updates deactivated remains intact, ensuring backward compatibility.

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

@rafiss rafiss merged commit de6e4fb into cockroachdb:release-24.1 Aug 27, 2025
16 checks passed
@rafiss rafiss deleted the backport24.1-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) v24.1.24
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants