-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: add support for dropping the primary region from a multi-region db
This patch adds support for dropping the primary region from a multi-region database. Dropping the primary region is allowed only if all other regions have been removed from the database. Put another way, the primary region is always the last region to go and the last region to go is always the primary region. As part of removing the last region from the database, all of the static sql state is also reverted, leaving no detritus from multi-region ways of old. In particular, this means that all GLOBAL and REGIONAL BY TABLE tables lose the locality config from their descriptor and the multi-region type descriptor is removed from the database. Dropping the last region can fail for a few of reasons: - A REGIONAL BY TABLE table is homed explicitly in the region being dropped. - A REGIONAL BY ROW table exists in the database (which must write the last region in all rows of its region column). - A table in the database uses the multi-region enum. All of these fail scenarios can be ascertained by checking if references on the type descriptor exist, without having to go through the general case of enum value removal that happens in the type schema changer. This is what we do. Lastly, it's worth noting this patch doesn't modify zone configurations. Closes #57391 Informs #58333 Release note (sql change): `ALTER DATABASE ... DROP REGION` now allows for dropping the primary region.
- Loading branch information
1 parent
952af3c
commit 14af57d
Showing
3 changed files
with
218 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters