Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql,keys: disregard checks in *ZoneConfig*Batch #109774

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

annrpom
Copy link
Contributor

@annrpom annrpom commented Aug 30, 2023

Previously, a bug occured where a transactional schema change,
ALTER RANGE default CONFIGURE ZONE..., statement would
produce a CPut failure, even though both statements do take effect.
This was due to a guard in the code that blocked us from adding the
first zone config to the uncommitted cache, causing the expValues
being updated to the KV batch to be the same for both statements.
This patch addresses the issue by removing the check and allowing
for default and psuedotables (like system ranges) to be added to
the uncommitted cache.

Epic: none
Release note (bug fix): two ALTER RANGE default CONFIGURE ZONE
statements on the same line no longer displays an error.
Fixes: #108253

@blathers-crl
Copy link

blathers-crl bot commented Aug 30, 2023

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

@annrpom annrpom marked this pull request as ready for review August 31, 2023 18:41
@annrpom annrpom requested a review from a team as a code owner August 31, 2023 18:41
@annrpom annrpom requested a review from nvanbenschoten August 31, 2023 18:41
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @annrpom and @nvanbenschoten)


pkg/sql/catalog/descs/collection.go line 558 at r1 (raw file):

	}

	if descID != keys.RootNamespaceID && !keys.IsPseudoTableID(uint32(descID)) {

i'm guessing if we do this change, we may want to remove this check too. but i'd like to understand this better.

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @annrpom and @nvanbenschoten)


pkg/sql/catalog/descs/collection.go line 558 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

i'm guessing if we do this change, we may want to remove this check too. but i'd like to understand this better.

The commit where this was added is ae5c0f6.

It may be related to the fact the RootNamespace and pseudo-tables both don't have descriptors... but i'm not sure

Copy link
Contributor Author

@annrpom annrpom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten and @rafiss)


pkg/sql/catalog/descs/collection.go line 558 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

The commit where this was added is ae5c0f6.

It may be related to the fact the RootNamespace and pseudo-tables both don't have descriptors... but i'm not sure

+1: also, not sure if I need to keep the check for IsPseudoTableID either - system ranges belong to this category & altering a system range's zone config was (edit: and still is) supported at the time of the commit linked

Copy link
Contributor Author

@annrpom annrpom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten and @rafiss)


pkg/sql/catalog/descs/collection.go line 558 at r1 (raw file):

Previously, annrpom (annie pompa) wrote…

+1: also, not sure if I need to keep the check for IsPseudoTableID either - system ranges belong to this category & altering a system range's zone config was supported at the time of the commit linked

update: the descID != keys.RootNamespaceID check makes sense in DeleteZoneConfigInBatch, but I also noticed that the following would throw an error before we get to this check:

} else if targetID == keys.RootNamespaceID && deleteZone {
return pgerror.Newf(pgcode.CheckViolation,
"cannot remove default zone")

@annrpom annrpom changed the title sql: disregard check for RootNameSpaceID sql: disregard checks in *ZoneConfig*Batch Sep 7, 2023
@annrpom annrpom requested a review from a team as a code owner September 7, 2023 14:14
Copy link
Contributor Author

@annrpom annrpom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafiss : [some for posterity] - after discussing with @Xiang-Gu, I aimed to fix this bug in the same nature Xiang detailed in # #88844 (heavy emphasis on the last paragraph in this commit); however, Chengxiong pointed out a good case for not solving it this way: this bug only happens in the case where descID == keys.RootNamespaceID || keys.IsPseudoTableID(uint32(descID))

in addition, no one can recall a proper reason as to why this check exists

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten and @rafiss)

@annrpom annrpom requested a review from rafiss September 7, 2023 14:25
@rafiss rafiss added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Sep 7, 2023
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your research into the history of this code! i think this solution is good

@annrpom annrpom changed the title sql: disregard checks in *ZoneConfig*Batch sql,keys: disregard checks in *ZoneConfig*Batch Sep 7, 2023
This patch updates the PseudoTableIDs list to replace
`PublicSchemaID` with `SystemPublicSchemaID`; while they
are both the same value, the former is outdated.

Epic: none
Fixes:
Release note: None
@annrpom annrpom force-pushed the singleline-alter branch 2 times, most recently from 4c64864 to a9588e9 Compare September 7, 2023 18:09
Previously, a bug occured where a transactional schema change,
 `ALTER RANGE default CONFIGURE ZONE...`, statement would
produce a CPut failure, even though both statements do take effect.
This was due to a guard in the code that blocked us from adding the
first zone config to the uncommitted cache, causing the expValues
being updated to the KV batch to be the same for both statements.
This patch addresses the issue by removing the check and allowing
for `default` and psuedotables (like system ranges) to be added to
the uncommitted cache.

Epic: none
Release note (bug fix): two `ALTER RANGE default CONFIGURE ZONE`
statements on the same line no longer displays an error.
Fixes: cockroachdb#108253
@annrpom
Copy link
Contributor Author

annrpom commented Sep 8, 2023

TFTR! ('-')7

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Sep 8, 2023

Build succeeded:

@craig craig bot merged commit 9db41b3 into cockroachdb:master Sep 8, 2023
@blathers-crl
Copy link

blathers-crl bot commented Sep 8, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from e56312f to blathers/backport-release-23.1-109774: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1.x failed. See errors above.


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

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

Successfully merging this pull request may close these issues.

Two ALTER commands on a single line fail
3 participants