Skip to content

Commit

Permalink
sql: disregard checks in *ZoneConfig*Batch
Browse files Browse the repository at this point in the history
Previously, a bug occured where a transactional schema change,
 `ALTER RANGE default CONFIGURE ZONE...`, statement would
produce a CPut failure, even though both statements do take effect.
This was due to a guard in the code that blocked us from adding the
first zone config to the uncommitted cache, causing the expValues
being updated to the KV batch to be the same for both statements.
This patch addresses the issue by removing the check and allowing
for `default` and psuedotables (like system ranges) to be added to
the uncommitted cache.

Epic: none
Release note (bug fix): two `ALTER RANGE default CONFIGURE ZONE`
statements on the same line no longer displays an error.
Fixes: #108253
  • Loading branch information
annrpom committed Sep 7, 2023
1 parent 7bab771 commit 2d9a10e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/sql/catalog/descs/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,7 @@ func (tc *Collection) WriteZoneConfigToBatch(
return err
}

if descID != keys.RootNamespaceID && !keys.IsPseudoTableID(uint32(descID)) {
return tc.AddUncommittedZoneConfig(descID, zc.ZoneConfigProto())
}
return nil
return tc.AddUncommittedZoneConfig(descID, zc.ZoneConfigProto())
}

// DeleteZoneConfigInBatch deletes zone config of the table.
Expand All @@ -555,9 +552,7 @@ func (tc *Collection) DeleteZoneConfigInBatch(
return err
}

if descID != keys.RootNamespaceID && !keys.IsPseudoTableID(uint32(descID)) {
tc.MarkUncommittedZoneConfigDeleted(descID)
}
tc.MarkUncommittedZoneConfigDeleted(descID)
return nil
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/zone_config
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,25 @@ bar 03:25:45
baz 04:00:00
vm 27:46:40
zc 27:46:40

statement error pgcode 23514 pq: cannot remove default zone
ALTER RANGE default CONFIGURE ZONE DISCARD;

subtest transactional_schemachanges

statement ok
CREATE DATABASE foo

statement ok
ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = 3; ALTER RANGE default CONFIGURE ZONE USING gc.ttlseconds = 4;

statement ok
ALTER RANGE meta CONFIGURE ZONE USING gc.ttlseconds = 3; ALTER RANGE meta CONFIGURE ZONE USING gc.ttlseconds = 4;

statement ok
ALTER RANGE meta CONFIGURE ZONE DISCARD; ALTER RANGE meta CONFIGURE ZONE DISCARD;

statement ok
ALTER DATABASE foo CONFIGURE ZONE USING gc.ttlseconds = 3; ALTER DATABASE foo CONFIGURE ZONE USING gc.ttlseconds = 4;

subtest end

0 comments on commit 2d9a10e

Please sign in to comment.