As "discovered" in #24154, we handle zone configs differently when dropping partitions/tables/databases.
When you drop a table, we keep the corresponding zone config around until the table's descriptor is deleted, which is supposed to happen after the configured GC TTL period.
I haven't tested dropping a partition, so I won't speak on it.
When you drop a database, we delete the corresponding zone config immediately.
The behavior when dropping a database is concerning. If (a) there's data in a table in the database (b) the table doesn't have a table-level zone config (c) the database does have a database-level zone config, then dropping the database (e.g. DROP DATABASE ... CASCADE) has the effect of changing the zone config that applies to the data in the table. Before dropping the database, the databases's zone config applies to the table. After dropping the database, the global .default zone config is all that applies to the table.
This means that when we drop a database, it can actually cause a lot of rebalancing if the database had different constraints on it than the .default zone. Even if the database was constrained to certain regions for sovereignty reasons, the yet-to-be-GC'ed data will likely get moved elsewhere.
For example, I created a 6 node local cluster with 3 nodes in locality a=1 and 3 in a=2. I created a table, split it 20 times, and constrained all its replicas to a=1 around 16:07 in the below screenshot. At 16:09 I ran DROP DATABASE ... CASCADE on the database, and suddenly all the data got spread around across both localities because the constraint I had specified no longer existed.
There may also be a similar problem with us deleting a table's zone config before all the data has been GC'ed. I'm not an expert in that area, though, so I'll let @benesch speak to that.
As "discovered" in #24154, we handle zone configs differently when dropping partitions/tables/databases.
The behavior when dropping a database is concerning. If (a) there's data in a table in the database (b) the table doesn't have a table-level zone config (c) the database does have a database-level zone config, then dropping the database (e.g.
DROP DATABASE ... CASCADE
) has the effect of changing the zone config that applies to the data in the table. Before dropping the database, the databases's zone config applies to the table. After dropping the database, the global.default
zone config is all that applies to the table.This means that when we drop a database, it can actually cause a lot of rebalancing if the database had different constraints on it than the
.default
zone. Even if the database was constrained to certain regions for sovereignty reasons, the yet-to-be-GC'ed data will likely get moved elsewhere.For example, I created a 6 node local cluster with 3 nodes in locality
a=1
and 3 ina=2
. I created a table, split it 20 times, and constrained all its replicas toa=1
around 16:07 in the below screenshot. At 16:09 I ranDROP DATABASE ... CASCADE
on the database, and suddenly all the data got spread around across both localities because the constraint I had specified no longer existed.There may also be a similar problem with us deleting a table's zone config before all the data has been GC'ed. I'm not an expert in that area, though, so I'll let @benesch speak to that.