@@ -4057,6 +4057,10 @@ func TestNonLinearChain(t *testing.T) {
4057
4057
4058
4058
sqlDB := sqlutils .MakeSQLRunner (tc .Conns [0 ])
4059
4059
4060
+ // This ensures a determenistic behavior to the relative number of files we
4061
+ // open during a restore when skipping a backup.
4062
+ sqlDB .Exec (t , `SET CLUSTER SETTING backup.index.read.enabled = true` )
4063
+
4060
4064
// Make a table with a row in it and make a full backup of it.
4061
4065
sqlDB .Exec (t , `CREATE TABLE t (a INT PRIMARY KEY)` )
4062
4066
sqlDB .Exec (t , `INSERT INTO t VALUES (0)` )
@@ -4110,15 +4114,14 @@ func TestNonLinearChain(t *testing.T) {
4110
4114
4111
4115
// Restore the same thing -- t2 -- we did before but now with the extra inc
4112
4116
// spur hanging out in the chain. This should produce the same result, and we
4113
- // would like it to only open two extra file2 to do so -- the manifest that
4114
- // includes the timestamps that then show it is not needed by the restore, and
4115
- // the checksum for said manifest.
4117
+ // would like it to only open one extra file to do so, just the index of the
4118
+ // incremental to show that it is not needed by the restore.
4116
4119
sqlDB .Exec (t , `DROP TABLE t` )
4117
4120
openedBefore = tc .Servers [0 ].MustGetSQLCounter ("cloud.readers_opened" )
4118
4121
sqlDB .Exec (t , `RESTORE TABLE defaultdb.t FROM LATEST IN $1` , localFoo )
4119
4122
sqlDB .CheckQueryResults (t , `SELECT * FROM t` , [][]string {{"0" }, {"1" }, {"2" }})
4120
4123
openedB := tc .Servers [0 ].MustGetSQLCounter ("cloud.readers_opened" ) - openedBefore
4121
- require .Equal (t , openedA + 2 , openedB )
4124
+ require .Equal (t , openedA + 1 , openedB )
4122
4125
4123
4126
// Finally, make sure we can restore from the tip of the spur, not just the
4124
4127
// tip of the chain.
@@ -6676,6 +6679,9 @@ INSERT INTO baz.bar VALUES (110, 'a'), (210, 'b'), (310, 'c'), (410, 'd'), (510,
6676
6679
func TestBackupRestoreInsideTenant (t * testing.T ) {
6677
6680
defer leaktest .AfterTest (t )()
6678
6681
defer log .Scope (t ).Close (t )
6682
+
6683
+ skip .UnderRace (t , "runs slow under race, ~10+ mins" )
6684
+
6679
6685
const numAccounts = 1
6680
6686
6681
6687
makeTenant := func (srv serverutils.TestServerInterface , tenant uint64 ) (* sqlutils.SQLRunner , func ()) {
@@ -6718,61 +6724,56 @@ func TestBackupRestoreInsideTenant(t *testing.T) {
6718
6724
defer cleanupT11C2 ()
6719
6725
6720
6726
t .Run ("tenant-backup" , func (t * testing.T ) {
6721
- // This test uses this mock HTTP server to pass the backup files between tenants.
6722
- httpAddr , httpServerCleanup := makeInsecureHTTPServer (t )
6723
- defer httpServerCleanup ()
6727
+ const collectionURI = "nodelocal://1/tenant-backup"
6724
6728
6725
- tenant10 .Exec (t , `BACKUP INTO $1` , httpAddr )
6729
+ tenant10 .Exec (t , `BACKUP INTO $1` , collectionURI )
6726
6730
6727
6731
t .Run ("cluster-restore" , func (t * testing.T ) {
6728
6732
t .Run ("into-same-tenant-id" , func (t * testing.T ) {
6729
- tenant10C2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6733
+ tenant10C2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6730
6734
tenant10C2 .CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6731
6735
})
6732
6736
t .Run ("into-different-tenant-id" , func (t * testing.T ) {
6733
- tenant11C2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6737
+ tenant11C2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6734
6738
tenant11C2 .CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6735
6739
})
6736
6740
t .Run ("into-system-tenant-id" , func (t * testing.T ) {
6737
- systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6741
+ systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6738
6742
systemDB2 .CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6739
6743
})
6740
6744
})
6741
6745
6742
6746
t .Run ("database-restore" , func (t * testing.T ) {
6743
6747
t .Run ("into-same-tenant-id" , func (t * testing.T ) {
6744
6748
tenant10 .Exec (t , `CREATE DATABASE foo2` )
6745
- tenant10 .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , httpAddr )
6749
+ tenant10 .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , collectionURI )
6746
6750
tenant10 .CheckQueryResults (t , `SELECT * FROM foo2.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6747
6751
})
6748
6752
t .Run ("into-different-tenant-id" , func (t * testing.T ) {
6749
6753
tenant11 .Exec (t , `CREATE DATABASE foo` )
6750
- tenant11 .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1` , httpAddr )
6754
+ tenant11 .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1` , collectionURI )
6751
6755
tenant11 .CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6752
6756
})
6753
6757
t .Run ("into-system-tenant-id" , func (t * testing.T ) {
6754
6758
systemDB .Exec (t , `CREATE DATABASE foo2` )
6755
- systemDB .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , httpAddr )
6759
+ systemDB .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , collectionURI )
6756
6760
systemDB .CheckQueryResults (t , `SELECT * FROM foo2.bar` , tenant10 .QueryStr (t , `SELECT * FROM foo.bar` ))
6757
6761
})
6758
6762
})
6759
6763
})
6760
6764
6761
6765
t .Run ("system-backup" , func (t * testing.T ) {
6762
- // This test uses this mock HTTP server to pass the backup files between tenants.
6763
- httpAddr , httpServerCleanup := makeInsecureHTTPServer (t )
6764
- defer httpServerCleanup ()
6766
+ const collectionURI = "nodelocal://1/system-backup"
6765
6767
6766
- systemDB .Exec (t , `BACKUP INTO $1 WITH include_all_virtual_clusters` , httpAddr )
6768
+ systemDB .Exec (t , `BACKUP INTO $1 WITH include_all_virtual_clusters` , collectionURI )
6767
6769
6768
6770
tenant20C2 , cleanupT20C2 := makeTenant (srv2 , 20 )
6769
6771
defer cleanupT20C2 ()
6770
6772
6771
6773
t .Run ("cluster-restore" , func (t * testing.T ) {
6772
6774
// Now restore a cluster backup taken from a system tenant that
6773
6775
// hasn't created any tenants.
6774
- httpAddrEmpty , cleanupEmptyHTTPServer := makeInsecureHTTPServer (t )
6775
- defer cleanupEmptyHTTPServer ()
6776
+ const emptyCollectionURI = "nodelocal://1/empty-system-backup"
6776
6777
6777
6778
_ , emptySystemDB , cleanupEmptyCluster := backupRestoreTestSetupEmpty (t , singleNode ,
6778
6779
dir , InitManualReplication , base.TestClusterArgs {
@@ -6782,13 +6783,13 @@ func TestBackupRestoreInsideTenant(t *testing.T) {
6782
6783
})
6783
6784
defer cleanupEmptyCluster ()
6784
6785
6785
- emptySystemDB .Exec (t , `BACKUP INTO $1` , httpAddrEmpty )
6786
- tenant20C2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddrEmpty )
6786
+ emptySystemDB .Exec (t , `BACKUP INTO $1` , emptyCollectionURI )
6787
+ tenant20C2 .Exec (t , `RESTORE FROM LATEST IN $1` , emptyCollectionURI )
6787
6788
})
6788
6789
6789
6790
t .Run ("database-restore-into-tenant" , func (t * testing.T ) {
6790
6791
tenant10 .Exec (t , `CREATE DATABASE data` )
6791
- tenant10 .Exec (t , `RESTORE TABLE data.bank FROM LATEST IN $1` , httpAddr )
6792
+ tenant10 .Exec (t , `RESTORE TABLE data.bank FROM LATEST IN $1` , collectionURI )
6792
6793
systemDB .CheckQueryResults (t , `SELECT * FROM data.bank` , tenant10 .QueryStr (t , `SELECT * FROM data.bank` ))
6793
6794
})
6794
6795
@@ -6814,9 +6815,8 @@ func TestBackupRestoreTenantSettings(t *testing.T) {
6814
6815
_ = securitytest .EmbeddedTenantIDs ()
6815
6816
6816
6817
systemDB .Exec (t , `ALTER TENANT ALL SET CLUSTER SETTING sql.notices.enabled = false` )
6817
- backup2HttpAddr , backup2Cleanup := makeInsecureHTTPServer (t )
6818
- defer backup2Cleanup ()
6819
- systemDB .Exec (t , `BACKUP INTO $1` , backup2HttpAddr )
6818
+ const collectionURI = "nodelocal://1/backup"
6819
+ systemDB .Exec (t , `BACKUP INTO $1` , collectionURI )
6820
6820
6821
6821
_ , systemDB2 , cleanupDB2 := backupRestoreTestSetupEmpty (t , singleNode , dir , InitManualReplication , base.TestClusterArgs {
6822
6822
ServerArgs : base.TestServerArgs {
@@ -6825,7 +6825,7 @@ func TestBackupRestoreTenantSettings(t *testing.T) {
6825
6825
})
6826
6826
defer cleanupDB2 ()
6827
6827
t .Run ("cluster-restore-into-cluster-with-tenant-settings-succeeds" , func (t * testing.T ) {
6828
- systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , backup2HttpAddr )
6828
+ systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6829
6829
systemDB2 .CheckQueryResults (t , `SELECT * FROM system.tenant_settings` , systemDB .QueryStr (t , `SELECT * FROM system.tenant_settings` ))
6830
6830
})
6831
6831
}
@@ -6892,60 +6892,55 @@ func TestBackupRestoreInsideMultiPodTenant(t *testing.T) {
6892
6892
tenant10 [0 ].Exec (t , `CREATE DATABASE foo; CREATE TABLE foo.bar(i int primary key); INSERT INTO foo.bar VALUES (110), (210), (310)` )
6893
6893
6894
6894
t .Run ("tenant-backup" , func (t * testing.T ) {
6895
- // This test uses this mock HTTP server to pass the backup files between tenants.
6896
- httpAddr , httpServerCleanup := makeInsecureHTTPServer (t )
6897
- defer httpServerCleanup ()
6895
+ const collectionURI = "nodelocal://1/tenant-backup"
6898
6896
6899
- tenant10 [0 ].Exec (t , `BACKUP INTO $1` , httpAddr )
6897
+ tenant10 [0 ].Exec (t , `BACKUP INTO $1` , collectionURI )
6900
6898
6901
6899
t .Run ("cluster-restore" , func (t * testing.T ) {
6902
6900
t .Run ("into-same-tenant-id" , func (t * testing.T ) {
6903
- tenant10C2 [0 ].Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6901
+ tenant10C2 [0 ].Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6904
6902
tenant10C2 [0 ].CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 [0 ].QueryStr (t , `SELECT * FROM foo.bar` ))
6905
6903
})
6906
6904
t .Run ("into-different-tenant-id" , func (t * testing.T ) {
6907
- tenant11C2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6905
+ tenant11C2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6908
6906
tenant11C2 .CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 [0 ].QueryStr (t , `SELECT * FROM foo.bar` ))
6909
6907
})
6910
6908
t .Run ("into-system-tenant-id" , func (t * testing.T ) {
6911
- systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddr )
6909
+ systemDB2 .Exec (t , `RESTORE FROM LATEST IN $1` , collectionURI )
6912
6910
})
6913
6911
})
6914
6912
6915
6913
t .Run ("database-restore" , func (t * testing.T ) {
6916
6914
t .Run ("into-same-tenant-id" , func (t * testing.T ) {
6917
6915
tenant10 [0 ].Exec (t , `CREATE DATABASE foo2` )
6918
- tenant10 [0 ].Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , httpAddr )
6916
+ tenant10 [0 ].Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , collectionURI )
6919
6917
tenant10 [0 ].CheckQueryResults (t , `SELECT * FROM foo2.bar` , tenant10 [0 ].QueryStr (t , `SELECT * FROM foo.bar` ))
6920
6918
})
6921
6919
t .Run ("into-different-tenant-id" , func (t * testing.T ) {
6922
6920
tenant11 [0 ].Exec (t , `CREATE DATABASE foo` )
6923
- tenant11 [0 ].Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1` , httpAddr )
6921
+ tenant11 [0 ].Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1` , collectionURI )
6924
6922
tenant11 [0 ].CheckQueryResults (t , `SELECT * FROM foo.bar` , tenant10 [0 ].QueryStr (t , `SELECT * FROM foo.bar` ))
6925
6923
})
6926
6924
t .Run ("into-system-tenant-id" , func (t * testing.T ) {
6927
6925
systemDB .Exec (t , `CREATE DATABASE foo2` )
6928
- systemDB .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , httpAddr )
6926
+ systemDB .Exec (t , `RESTORE TABLE foo.bar FROM LATEST IN $1 WITH into_db='foo2'` , collectionURI )
6929
6927
systemDB .CheckQueryResults (t , `SELECT * FROM foo2.bar` , tenant10 [0 ].QueryStr (t , `SELECT * FROM foo.bar` ))
6930
6928
})
6931
6929
})
6932
6930
})
6933
6931
6934
6932
t .Run ("system-backup" , func (t * testing.T ) {
6935
- // This test uses this mock HTTP server to pass the backup files between tenants.
6936
- httpAddr , httpServerCleanup := makeInsecureHTTPServer (t )
6937
- defer httpServerCleanup ()
6933
+ const collectionURI = "nodelocal://1/system-backup"
6938
6934
6939
- systemDB .Exec (t , `BACKUP INTO $1 WITH include_all_virtual_clusters` , httpAddr )
6935
+ systemDB .Exec (t , `BACKUP INTO $1 WITH include_all_virtual_clusters` , collectionURI )
6940
6936
6941
6937
tenant20C2 , cleanupT20C2 := makeTenant (srv2 , 20 , false )
6942
6938
defer cleanupT20C2 ()
6943
6939
6944
6940
t .Run ("cluster-restore" , func (t * testing.T ) {
6945
6941
// Now restore a cluster backup taken from a system tenant that
6946
6942
// hasn't created any tenants.
6947
- httpAddrEmpty , cleanupEmptyHTTPServer := makeInsecureHTTPServer (t )
6948
- defer cleanupEmptyHTTPServer ()
6943
+ const emptyCollectionURI = "nodelocal://1/empty-system-backup"
6949
6944
6950
6945
_ , emptySystemDB , cleanupEmptyCluster := backupRestoreTestSetupEmpty (t , singleNode ,
6951
6946
dir , InitManualReplication , base.TestClusterArgs {
@@ -6955,13 +6950,13 @@ func TestBackupRestoreInsideMultiPodTenant(t *testing.T) {
6955
6950
})
6956
6951
defer cleanupEmptyCluster ()
6957
6952
6958
- emptySystemDB .Exec (t , `BACKUP INTO $1` , httpAddrEmpty )
6959
- tenant20C2 .Exec (t , `RESTORE FROM LATEST IN $1` , httpAddrEmpty )
6953
+ emptySystemDB .Exec (t , `BACKUP INTO $1` , emptyCollectionURI )
6954
+ tenant20C2 .Exec (t , `RESTORE FROM LATEST IN $1` , emptyCollectionURI )
6960
6955
})
6961
6956
6962
6957
t .Run ("database-restore-into-tenant" , func (t * testing.T ) {
6963
6958
tenant10 [0 ].Exec (t , `CREATE DATABASE data` )
6964
- tenant10 [0 ].Exec (t , `RESTORE TABLE data.bank FROM LATEST IN $1` , httpAddr )
6959
+ tenant10 [0 ].Exec (t , `RESTORE TABLE data.bank FROM LATEST IN $1` , collectionURI )
6965
6960
systemDB .CheckQueryResults (t , `SELECT * FROM data.bank` , tenant10 [0 ].QueryStr (t , `SELECT * FROM data.bank` ))
6966
6961
})
6967
6962
})
0 commit comments