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

release-21.1: sql: stop duplicating regions on the database descriptor #62200

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

arulajmani
Copy link
Collaborator

Backport 1/1 commits from #61585.

/cc @cockroachdb/release


Previously, we were duplicating regions both on the type descriptor and
the database descriptor. Theres a verbose explanation about why this is
bad on the linked issue, but the crux of the problem with this approach
is the added complexity it requires keeping these two lists in sync as
regions are added/dropped from a database in the face of possible
failure scenarios.

This patch removes the Regions field from the database descriptors's
region config. Instead, the regions stored on the multi-region enum
serve as the sole source of truth. To accomplish this, we introduce a
new RegionConfig struct which is synthesized from the state (primary
region, survival goal) stored on the database and the state (available
regions) stored on the type descriptor. All the places that constructed
zone configurations from the raw region config proto now use this new
struct. This patch also introduces a InitializationRegionConfig
struct which wraps a RegionConfig with initilization specific
meta-data.

I'm not too thrilled by the fact that survival goal and primary region
is still stored on the database descriptor. Ideally, the database
descriptor would contain just the multi-region enum ID and all user
configured parameters would be in one place (on the type descriptor's
region config). The level of indirection introduced by this patch sets
us on the path to that future.

Closes #60620

Release justification: low risk updates to new functionality
Release note: None

Previously, we were duplicating regions both on the type descriptor and
the database descriptor. Theres a verbose explanation about why this is
bad on the linked issue, but the crux of the problem with this approach
is the added complexity it requires keeping these two lists in sync as
regions are added/dropped from a database in the face of possible
failure scenarios.

This patch removes the `Regions` field from the database descriptors's
region config. Instead, the regions stored on the multi-region enum
serve as the sole source of truth. To accomplish this, we introduce a
new `RegionConfig` struct which is synthesized from the state (primary
region, survival goal) stored on the database and the state (available
regions) stored on the type descriptor. All the places that constructed
zone configurations from the raw region config proto now use this new
struct. This patch also introduces a `InitializationRegionConfig`
struct which wraps a `RegionConfig` with initilization specific
meta-data.

I'm not too thrilled by the fact that survival goal and primary region
is still stored on the database descriptor. Ideally, the database
descriptor would contain just the multi-region enum ID and all user
configured parameters would be in one place (on the type descriptor's
region config). The level of indirection introduced by this patch sets
us on the path to that future.

Closes cockroachdb#60620

Release justification: low risk updates to new functionality
Release note: None
@arulajmani arulajmani requested review from otan, ajstorm, a team and miretskiy and removed request for a team March 18, 2021 14:34
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@ajstorm ajstorm left a comment

Choose a reason for hiding this comment

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

Reviewed 39 of 39 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @miretskiy and @otan)

@arulajmani arulajmani merged commit db73aa5 into cockroachdb:release-21.1 Mar 18, 2021
ajstorm added a commit to ajstorm/cockroach that referenced this pull request Mar 22, 2021
…tion

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by cockroachdb#62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Release note: None
ajstorm added a commit to ajstorm/cockroach that referenced this pull request Mar 23, 2021
…tion

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by cockroachdb#62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Release note: None
ajstorm added a commit to ajstorm/cockroach that referenced this pull request Mar 23, 2021
…tion

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by cockroachdb#62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Release note: None
ajstorm added a commit to ajstorm/cockroach that referenced this pull request Mar 24, 2021
…tion

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by cockroachdb#62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Release note: None
craig bot pushed a commit that referenced this pull request Mar 24, 2021
62354: sql: Don't require override for multiple MR abstractions in a transaction r=arulajmani a=ajstorm

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by #62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Resolves: #61551 

Release note: None

Co-authored-by: Adam Storm <storm@cockroachlabs.com>
ajstorm added a commit to ajstorm/cockroach that referenced this pull request Mar 24, 2021
…tion

Previously, we required override_multi_region_zone_config to be
specified if multiple add/drop region operations were included in a
single transaction. This was due to the fact that the RegionConfig
would get updated as part of the first operation, but the zone
configurations to which we were comparing were not updated until the
transaction committed. This issue was fixed in part by cockroachdb#62200, but this
PR finishes the job by creating a function which synthesizes a zone
configuration which presents the state of the RegionConfig at the
beginning of the transaction.

Release note: None
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