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: refactor SynthesizeRegionConfig usages #63512

Merged
merged 1 commit into from
Apr 15, 2021

Conversation

otan
Copy link
Contributor

@otan otan commented Apr 13, 2021

Use the option method instead to decide to read from the cache.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the use_unleased branch 2 times, most recently from 58e4f67 to f4a3054 Compare April 14, 2021 00:31
@otan otan marked this pull request as ready for review April 14, 2021 00:31
@otan otan requested a review from arulajmani April 14, 2021 00:31
@otan otan force-pushed the use_unleased branch 3 times, most recently from 25a18c5 to 3325ca4 Compare April 14, 2021 06:06
Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

This may break the following (contrived) scenario:

  • Client 1: ALTER DATABASE ... DROP REGION "us-east"
  • Client 2: CREATE TABLE t() LOCALITY REGIONAL BY ROW
  • Client 3, which (say) has version v-1 of the type descriptor, validate_multi_region_zone_configs() <--- Fails because it expects t to have a partition for "us-east"

This is because on version v-1 "us-east" is public, so we'll validate for it. Granted, this is quite contrived, but maybe one round-trip is a fair enough price to pay here for our sanity? Wdyt?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@otan
Copy link
Contributor Author

otan commented Apr 15, 2021

I would think client 3 in this case would also have v1 of the zone config.

Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

Maybe I'm missing something, but aren't we reading zone configs from the system.zone table?

Also, independent of round trip/no round trip, I like the way this PR cleans up the code so we should get it in in some form.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@otan
Copy link
Contributor Author

otan commented Apr 15, 2021

Would've thought leasing would also mean the reads would be at an earlier timestamp when reading system.zones, but maybe I'm jumping too many hurdles. I'll revert the round-trip bit for now, but keep the refactor for SynthesizeRegionConfig

@otan otan changed the title sql: use cache for crdb_internal.validate_multi_region_zone_configs() sql: refactor SynthesizeRegionConfig usages Apr 15, 2021
Copy link
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @otan)


pkg/sql/region_util.go, line 889 at r1 (raw file):

// CurrentDatabaseRegionConfig is part of the tree.EvalDatabase interface.
// CurrentDatabaseRegionConfig uses the cache to synthesize the RegionConfig
// and as such is intended for DML use. It returns an nil

nit: s/returns an nil/returns nil/g

Use the option method instead to decide to read from the cache.

Release note: None
@otan
Copy link
Contributor Author

otan commented Apr 15, 2021

bors r=arulajmani

@craig
Copy link
Contributor

craig bot commented Apr 15, 2021

🕐 Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@craig
Copy link
Contributor

craig bot commented Apr 15, 2021

Build succeeded:

@craig craig bot merged commit fc77ea5 into cockroachdb:master Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants