-
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.
59989: sql: add support for dropping regions from multi-region databases (no denormalization) r=otan a=arulajmani This patch builds upon the drop enum infrastructure to add the ability to drop regions from a multi-region database. It adds support for dropping any region that isn't the primary region. That change is forthcoming. When dropping a region, the multi-region enum entry is moved to "READ_ONLY" capability. This is followed by validation in the type schema changer to ascertain that no table is using the region value being dropped in one of its rows. The database descriptor, which unfortunately duplicates the list of regions, also loses the region entry when the value is moved to "READ ONLY" mode. If validation is successful, the region is removed from the multi-region enum. If, however, validation is unsuccessful, the region value is moved back to `PUBLIC` and the entry is restored on the database descriptor. Special behavior around REGIONAL BY TABLE tables and the effect of that on type descriptor dependencies is also worth calling out here. Previously, these tables did not capture their "implicit" bidirectional dependency with the multi-region type descriptor. The dependency is described as implicit because even though no column on the table uses the multi-region type descriptor to store the homing region, a value from the type descriptor is stored on the table's locality config. This dependency must be checked against when dropping regions or the type descriptor itself. Before this patch, all dependencies a table had with any type descriptor could be constructed from the column descriptors on the table descriptor. As mentioned previously, this is no longer possible now that we have REGIONAL BY TABLE tables in the mix. As such, this requires modifying how type references are constructed for a table descriptor. In particular, if a table is a REGIONAL BY TABLE table homed in an explicit (non-primary) region, the multi-region enum ID is read off the database descriptor and added to the list of types referenced by the table descriptor. Now that a particular locality config state may have this implicit dependency, switching locality patterns now requires us to be cognizant of it. This is to say, when moving from a locality pattern that has a dependency on the multi-region type descriptor to one that does not, the back reference must be removed (and vice-versa). As such, modifying the descriptor directly is discourage.Instead, new methods of the form `alterTableDescLocality...` are provided which negotiate the dependency linking/unlinking appropriately. Lastly, this patch also adds validation to ensure that every REGIONAL BY TABLE table that is homed in an explicit region stores a reference to the multi-region type descriptor. The validation semantics around REGIONAL BY TABLE tables and GLOBAL tables are also handled appropriately. Informs #58333 Closes #57389 Release note (sql change): ALTER DATABASE ... DROP REGION is now implemented. Co-authored-by: arulajmani <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,685 additions
and
545 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
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
Oops, something went wrong.