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: ensure graceful rollbacks if the ADD REGION async job fails #60762

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

arulajmani
Copy link
Collaborator

Previously, we assumed that the async component of an
ALTER DATABASE ... ADD REGION wouldn't fail. This isn't really true
though, because users may cancel jobs or we may be dropping regions in
the same txn that fails validation.

We have validation that ensures every region (READ ONLY or PUBLIC) on
the multi-region type descriptor is also present on the database
descriptor's region config (and vice-versa). If we realize that a region
can't be promoted from READ ONLY to PUBLIC, we must also remove it from
the database descriptor's region config (in addition removing it from
the type descriptor). Prior to this patch we didn't do so, and cleanup
could potentially fail validation. This patch fixes that behavior. This
is a temporary band-aid until we stop denormalizing region values and
have a single source of truth.

Release note: None

@arulajmani arulajmani requested review from otan, ajstorm and a team February 19, 2021 01:04
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm and @arulajmani)


pkg/sql/multiregion_test.go, line 205 at r1 (raw file):

	if count != 1 {
		t.Fatal("expected crdb_internal_region to be present in system.namespace")

nit: delete

Previously, we assumed that the async component of an
`ALTER DATABASE ... ADD REGION` wouldn't fail. This isn't really true
though, because users may cancel jobs or we may be dropping regions in
the same txn that fails validation.

We have validation that ensures every region (READ ONLY or PUBLIC) on
the multi-region type descriptor is also present on the database
descriptor's region config (and vice-versa). If we realize that a region
can't be promoted from READ ONLY to PUBLIC, we must also remove it from
the database descriptor's region config (in addition removing it from
the type descriptor). Prior to this patch we didn't do so, and cleanup
could potentially fail validation. This patch fixes that behavior. This
is a temporary band-aid until we stop denormalizing region values and
have a single source of truth.

Release note: None
@arulajmani
Copy link
Collaborator Author

TFTR!

bors r=otan

@arulajmani arulajmani changed the title sql: ensure graceful for rollbacks if the ADD REGION async job fails sql: ensure graceful rollbacks if the ADD REGION async job fails Feb 19, 2021
@craig
Copy link
Contributor

craig bot commented Feb 19, 2021

Build succeeded:

@craig craig bot merged commit 83e70ce into cockroachdb:master Feb 19, 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