-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: adding/removing locality config on first region add/last region drop doesn't account for privileges #61003
Description
Describe the problem
For illustration, consider:
cockroach/pkg/sql/alter_database.go
Line 573 in 9e41034
| if err := forEachTableDesc(ctx, p, desc, hideVirtual, |
The API used here, ForEachTableDesc filters out descriptors that the user doesn't have visibility to (per privileges/ownership). This opens us up to a scenario where a user may add a region to a database but not modify all of the tables that exist inside the database with the default locality config. Later, when such a table is accessed, it will fail validation as we explicitly ensure all tables inside a MR database have a locality config set on them.
Expected behavior
In the illustration above, adding a region should fail if the user doesn't have permissions to modify all of the tables inside the database. Separately, the choice of API (ForEachTableDesc) is completely wrong here.
Additional context
This issue also manifests itself when we repartition Regional By Table tables when adding/dropping subsequent regions (albeit slightly differently).