-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60257: sql: Allow for multi-region database restores r=otan,arulajmani,pbardea a=ajstorm Until this commit, restores of multi-region databases failed due to the fact that the multi-region enum's type ID was changing as part of the restore. This commit remaps the enum ID so that the restore succeeds. The commit also rebuilds the database-level zone configuration. The table level zone configurations will be handled in a follow-on PR. Release note (sql change): Adds support for restore of multi-region databases. Co-authored-by: Adam Storm <[email protected]>
- Loading branch information
Showing
4 changed files
with
284 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
# LogicTest: multiregion-9node-3region-3azs | ||
|
||
query TTTT | ||
SHOW REGIONS | ||
---- | ||
ap-southeast-2 {ap-az1,ap-az2,ap-az3} {} {} | ||
ca-central-1 {ca-az1,ca-az2,ca-az3} {} {} | ||
us-east-1 {us-az1,us-az2,us-az3} {} {} | ||
|
||
statement ok | ||
CREATE DATABASE mr_backup primary region "ca-central-1" regions "ap-southeast-2", "us-east-1" | ||
|
||
statement ok | ||
CREATE DATABASE mr_backup_2 primary region "ap-southeast-2" regions "ca-central-1", "us-east-1" | ||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup | ||
---- | ||
DATABASE mr_backup ALTER DATABASE mr_backup CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ca-central-1]', | ||
lease_preferences = '[[+region=ca-central-1]]' | ||
|
||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup_2 | ||
---- | ||
DATABASE mr_backup_2 ALTER DATABASE mr_backup_2 CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ap-southeast-2]', | ||
lease_preferences = '[[+region=ap-southeast-2]]' | ||
|
||
statement ok | ||
ALTER DATABASE mr_backup CONFIGURE ZONE USING gc.ttlseconds = 1; | ||
ALTER DATABASE mr_backup_2 CONFIGURE ZONE USING gc.ttlseconds = 1 | ||
|
||
statement ok | ||
BACKUP DATABASE mr_backup TO 'nodelocal://self/mr_backup/'; | ||
BACKUP DATABASE mr_backup_2 TO 'nodelocal://self/mr_backup_2/'; | ||
BACKUP DATABASE mr_backup, mr_backup_2 TO 'nodelocal://self/mr_backup_combined/' | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
mr_backup | ||
mr_backup_2 | ||
postgres | ||
system | ||
test | ||
|
||
statement ok | ||
DROP DATABASE mr_backup; | ||
DROP DATABASE mr_backup_2 | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
postgres | ||
system | ||
test | ||
|
||
statement ok | ||
RESTORE DATABASE mr_backup FROM 'nodelocal://self/mr_backup/' | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
mr_backup | ||
postgres | ||
system | ||
test | ||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup | ||
---- | ||
DATABASE mr_backup ALTER DATABASE mr_backup CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ca-central-1]', | ||
lease_preferences = '[[+region=ca-central-1]]' | ||
|
||
statement ok | ||
RESTORE DATABASE mr_backup_2 FROM 'nodelocal://self/mr_backup_2/' | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
mr_backup | ||
mr_backup_2 | ||
postgres | ||
system | ||
test | ||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup_2 | ||
---- | ||
DATABASE mr_backup_2 ALTER DATABASE mr_backup_2 CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ap-southeast-2]', | ||
lease_preferences = '[[+region=ap-southeast-2]]' | ||
|
||
statement ok | ||
DROP DATABASE mr_backup; | ||
DROP DATABASE mr_backup_2 | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
postgres | ||
system | ||
test | ||
|
||
statement ok | ||
RESTORE DATABASE mr_backup, mr_backup_2 FROM 'nodelocal://self/mr_backup_combined/' | ||
|
||
query T | ||
select database_name from [show databases] | ||
---- | ||
defaultdb | ||
mr_backup | ||
mr_backup_2 | ||
postgres | ||
system | ||
test | ||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup | ||
---- | ||
DATABASE mr_backup ALTER DATABASE mr_backup CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ca-central-1]', | ||
lease_preferences = '[[+region=ca-central-1]]' | ||
|
||
query TT | ||
SHOW ZONE CONFIGURATION FOR DATABASE mr_backup_2 | ||
---- | ||
DATABASE mr_backup_2 ALTER DATABASE mr_backup_2 CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 90000, | ||
num_replicas = 5, | ||
num_voters = 3, | ||
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}', | ||
voter_constraints = '[+region=ap-southeast-2]', | ||
lease_preferences = '[[+region=ap-southeast-2]]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters