Skip to content

Conversation

@blathers-crl
Copy link

@blathers-crl blathers-crl bot commented Oct 24, 2025

Backport 1/1 commits from #156105 on behalf of @mw5h.


Previously, when the optimizer stored the ordinal of an index to use for writing tombstones in non-SERIALIZABLE transactions, it would call the Ordinal() method, which returns the value from the table's descriptor. We would later use this value as an input to the Index() method to retrieve the index in question. However, Ordinal() can differ from the catalog's view of the schema during schema change, resulting in sometimes getting the wrong index ordinal from the optimizer's point of view, sometimes resulting in an out of bounds error.

This patch switches the ordinal we save to be the actual index used when creating the optTable, which feels janky, but is at least correct.

Fixes: #151477
Release note (bug fix): A bug which could occasionally cause DML on regional by row tables with unique indexes that don't reference the region to fail under READ-COMMITTED isolation has been corrected.


Release justification: Simple fix for problem found in testing.

Previously, when the optimizer stored the ordinal of an index to use for
writing tombstones in non-SERIALIZABLE transactions, it would call the
Ordinal() method, which returns the value from the table's descriptor.
We would later use this value as an input to the Index() method to
retrieve the index in question. However, Ordinal() can differ from the
catalog's view of the schema during schema change, resulting in
sometimes getting the wrong index ordinal from the optimizer's point of
view, sometimes resulting in an out of bounds error.

This patch switches the ordinal we save to be the actual index used when
creating the optTable, which feels janky, but is at least correct.

Fixes: #151477
Release note (bug fix): A bug which could occasionally cause DML on
regional by row tables with unique indexes that don't reference the
region to fail under READ-COMMITTED isolation has been corrected.
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-25.3-156105 branch from 989688a to 168fa73 Compare October 24, 2025 21:45
@blathers-crl blathers-crl bot requested a review from a team as a code owner October 24, 2025 21:45
@blathers-crl blathers-crl bot requested review from mgartner and removed request for a team October 24, 2025 21:45
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Oct 24, 2025
@blathers-crl
Copy link
Author

blathers-crl bot commented Oct 24, 2025

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot requested a review from michae2 October 24, 2025 21:45
@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Oct 24, 2025
@blathers-crl
Copy link
Author

blathers-crl bot commented Oct 24, 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

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-queries SQL Queries Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants