-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: stop duplicating list of regions on the database descriptor #60620
Description
The multi-region type descriptor is the source of truth for available regions on a database. Currently, we duplicate the LogicalRepresentations from the type descriptor on to the database descriptor's region config. This wasn't problematic when enum promotion from READ_ONLY to PUBLIC couldn't fail, but with the support for dropping enum values in general and region removal specifically, this is no holds true. Currently, we have a rather delicate dance to keep the descriptors sane -- regions are added/removed in two steps, but the database descriptors are oblivious to this subtlety.
Consider the example of dropping regions from a database. Currently, we move the region on the type descriptor to READ ONLY mode and remove the region from the database descriptor. If the region removal validation fails, we must not only revert the enum member to PUBLIC, but also add the region back on to the database descriptor. This gets even more thorny to account for and test when these operations are performed inside transactions. It's also worth noting that even though we have validation to check our view of the world is sane, it doesn't help us in the face of an inconsistency bug -- it'll require descriptor surgery to make the database accessible again.
We should stop duplicating regions on the database descriptor. Instead, the multi-region enum should be the only source of truth on which regions are available to the database.