Skip to content

Commit

Permalink
Merge #52984
Browse files Browse the repository at this point in the history
52984: sql: make RemoveIndexZoneConfigs a noop when run on behalf of a tenant r=rohany,nvanbenschoten a=asubiotto

RemoveIndexZoneConfigs would previously return an error when run on behalf of
a tenant because it attempts to write a zone config. This would cause some
operations like index truncation to fail unnecessarily.

Release note: None (multitenancy)

Fixes #52558

Co-authored-by: Alfonso Subiotto Marques <[email protected]>
  • Loading branch information
craig[bot] and asubiotto committed Aug 19, 2020
2 parents ca8fc72 + eb5777c commit a4286e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/alter_primary_key
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# LogicTest: !3node-tenant(52558)

statement ok
SET experimental_enable_hash_sharded_indexes = true

Expand Down
7 changes: 6 additions & 1 deletion pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,14 +1291,19 @@ func (sc *SchemaChanger) done(ctx context.Context) error {
}

// maybeUpdateZoneConfigsForPKChange moves zone configs for any rewritten
// indexes from the old index over to the new index.
// indexes from the old index over to the new index. Noop if run on behalf of a
// tenant.
func maybeUpdateZoneConfigsForPKChange(
ctx context.Context,
txn *kv.Txn,
execCfg *ExecutorConfig,
table *sqlbase.MutableTableDescriptor,
swapInfo *descpb.PrimaryKeySwap,
) error {
if !execCfg.Codec.ForSystemTenant() {
// Tenants are agnostic to zone configs.
return nil
}
zone, err := getZoneConfigRaw(ctx, txn, execCfg.Codec, table.ID)
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ func getZoneConfigRaw(

// RemoveIndexZoneConfigs removes the zone configurations for some
// indexs being dropped. It is a no-op if there is no zone
// configuration.
// configuration or run on behalf of a tenant.
//
// It operates entirely on the current goroutine and is thus able to
// reuse an existing client.Txn safely.
Expand All @@ -912,6 +912,10 @@ func RemoveIndexZoneConfigs(
tableID descpb.ID,
indexDescs []descpb.IndexDescriptor,
) error {
if !execCfg.Codec.ForSystemTenant() {
// Tenants are agnostic to zone configs.
return nil
}
desc, err := catalogkv.GetDescriptorByID(ctx, txn, execCfg.Codec, tableID,
catalogkv.Mutable, catalogkv.TableDescriptorKind, true)
if err != nil {
Expand Down

0 comments on commit a4286e9

Please sign in to comment.