diff --git a/pkg/ccl/backupccl/restore_old_versions_test.go b/pkg/ccl/backupccl/restore_old_versions_test.go index cafe63daf5fc..7f4b1db7e7b2 100644 --- a/pkg/ccl/backupccl/restore_old_versions_test.go +++ b/pkg/ccl/backupccl/restore_old_versions_test.go @@ -69,7 +69,6 @@ func TestRestoreOldVersions(t *testing.T) { exportDirsWithoutInterleave = testdataBase + "/exports-without-interleaved" fkRevDirs = testdataBase + "/fk-rev-history" clusterDirs = testdataBase + "/cluster" - exceptionalDirs = testdataBase + "/exceptional" privilegeDirs = testdataBase + "/privileges" multiRegionDirs = testdataBase + "/multi-region" publicSchemaDirs = testdataBase + "/public-schema-remap" @@ -129,112 +128,6 @@ func TestRestoreOldVersions(t *testing.T) { } }) - // exceptional backups are backups that were possible to generate on old - // versions, but are now disallowed, but we should check that we fail - // gracefully with them. - t.Run("exceptional-backups", func(t *testing.T) { - t.Run("duplicate-db-desc", func(t *testing.T) { - backupUnderTest := "doubleDB" - /* - This backup was generated with the following SQL on (v21.1.6): - - CREATE DATABASE db1; - DROP DATABASE db1; - CREATE DATABASE db1; - BACKUP TO 'nodelocal://1/doubleDB' WITH revision_history; - */ - dir, err := os.Stat(filepath.Join(exceptionalDirs, backupUnderTest)) - require.NoError(t, err) - require.True(t, dir.IsDir()) - - // We could create tables which reference types in another database on - // 20.2 release candidates. - exportDir, err := filepath.Abs(filepath.Join(exceptionalDirs, dir.Name())) - require.NoError(t, err) - - externalDir, dirCleanup := testutils.TempDir(t) - ctx := context.Background() - tc := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ - ServerArgs: base.TestServerArgs{ - // Disabling the default test tenant due to test cases - // failures. More investigation is required. Tracked with - // #76378. - DisableDefaultTestTenant: true, - ExternalIODir: externalDir, - }, - }) - sqlDB := sqlutils.MakeSQLRunner(tc.Conns[0]) - defer func() { - tc.Stopper().Stop(ctx) - dirCleanup() - }() - err = os.Symlink(exportDir, filepath.Join(externalDir, "foo")) - require.NoError(t, err) - - sqlDB.Exec(t, `RESTORE FROM $1`, localFoo) - sqlDB.Exec(t, `DROP DATABASE db1;`) - sqlDB.Exec(t, `RESTORE DATABASE db1 FROM $1`, localFoo) - sqlDB.CheckQueryResults(t, - `SELECT count(*) FROM [SHOW DATABASES] WHERE database_name = 'db1'`, - [][]string{{"1"}}, - ) - }) - - t.Run("x-db-type-reference", func(t *testing.T) { - backupUnderTest := "xDbRef" - /* - This backup was generated with the following SQL: - - CREATE TYPE t AS ENUM ('foo'); - CREATE TABLE tbl (a t); - CREATE DATABASE otherdb; - ALTER TABLE tbl RENAME TO otherdb.tbl; - BACKUP DATABASE otherdb TO 'nodelocal://1/xDbRef'; - - This was permitted on some release candidates of v20.2. (#55709) - */ - dir, err := os.Stat(filepath.Join(exceptionalDirs, backupUnderTest)) - require.NoError(t, err) - require.True(t, dir.IsDir()) - - // We could create tables which reference types in another database on - // 20.2 release candidates. - exportDir, err := filepath.Abs(filepath.Join(exceptionalDirs, dir.Name())) - require.NoError(t, err) - - externalDir, dirCleanup := testutils.TempDir(t) - ctx := context.Background() - tc := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ - ServerArgs: base.TestServerArgs{ - ExternalIODir: externalDir, - }, - }) - sqlDB := sqlutils.MakeSQLRunner(tc.Conns[0]) - defer func() { - tc.Stopper().Stop(ctx) - dirCleanup() - }() - err = os.Symlink(exportDir, filepath.Join(externalDir, "foo")) - require.NoError(t, err) - - // Expect this restore to fail. - sqlDB.ExpectErr(t, `type "t" has unknown ParentID 50`, `RESTORE DATABASE otherdb FROM $1`, localFoo) - - // Expect that we don't crash and that we emit NULL for data that we - // cannot resolve (e.g. missing database descriptor, create_statement). - sqlDB.CheckQueryResults(t, ` -SELECT - database_name, parent_schema_name, object_name, object_type, create_statement -FROM [SHOW BACKUP SCHEMAS '`+localFoo+`' WITH privileges] -ORDER BY object_type, object_name`, [][]string{ - {"NULL", "NULL", "otherdb", "database", "NULL"}, - {"otherdb", "public", "tbl", "table", "NULL"}, - {"NULL", "public", "_t", "type", "NULL"}, - {"NULL", "public", "t", "type", "NULL"}, - }) - }) - }) - t.Run("zoneconfig_privilege_restore", func(t *testing.T) { dirs, err := os.ReadDir(privilegeDirs) require.NoError(t, err) diff --git a/pkg/ccl/backupccl/testdata/backup-restore/regression-tests b/pkg/ccl/backupccl/testdata/backup-restore/regression-tests new file mode 100644 index 000000000000..6f085c0ad295 --- /dev/null +++ b/pkg/ccl/backupccl/testdata/backup-restore/regression-tests @@ -0,0 +1,36 @@ +new-cluster name=s1 +---- + +subtest double-db + +exec-sql +CREATE DATABASE db1; +DROP DATABASE db1; +CREATE DATABASE db1; +---- + +exec-sql +BACKUP INTO 'nodelocal://1/doubleDB' WITH revision_history; +---- + +new-cluster name=s2 share-io-dir=s1 +---- + +exec-sql +RESTORE FROM LATEST IN 'nodelocal://1/doubleDB' +---- + +exec-sql +DROP DATABASE db1; +---- + +exec-sql +RESTORE DATABASE db1 FROM LATEST IN 'nodelocal://1/doubleDB'; +---- + +query-sql +SELECT count(*) FROM [SHOW DATABASES] WHERE database_name = 'db1' +---- +1 + +subtest end diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-682219251044745217-CHECKSUM b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-682219251044745217-CHECKSUM deleted file mode 100644 index c93b363acfce..000000000000 --- a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-682219251044745217-CHECKSUM +++ /dev/null @@ -1 +0,0 @@ -?åtÉ \ No newline at end of file diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-CHECKSUM b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-CHECKSUM deleted file mode 100644 index c93b363acfce..000000000000 --- a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-CHECKPOINT-CHECKSUM +++ /dev/null @@ -1 +0,0 @@ -?åtÉ \ No newline at end of file diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-STATISTICS b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP-STATISTICS deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST deleted file mode 100644 index af61f763a5ac..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST-CHECKSUM b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST-CHECKSUM deleted file mode 100644 index 0a08067d837c..000000000000 --- a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/BACKUP_MANIFEST-CHECKSUM +++ /dev/null @@ -1 +0,0 @@ -ïsS¯ \ No newline at end of file diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256804900865.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256804900865.sst deleted file mode 100644 index d65e4ebe1d6e..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256804900865.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256805654532.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256805654532.sst deleted file mode 100644 index e0b8978b1390..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256805654532.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256806211585.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256806211585.sst deleted file mode 100644 index d6b5f926fd99..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256806211585.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256807063553.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256807063553.sst deleted file mode 100644 index 529bad9d9b4c..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256807063553.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808407042.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808407042.sst deleted file mode 100644 index 8592c5fc44b0..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808407042.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808538114.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808538114.sst deleted file mode 100644 index 42aba5acde43..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256808538114.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954355713.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954355713.sst deleted file mode 100644 index c3f65779968b..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954355713.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954388481.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954388481.sst deleted file mode 100644 index 1801d2c19e4f..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256954388481.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256957206529.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256957206529.sst deleted file mode 100644 index 57b7254fd96e..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219256957206529.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257023922177.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257023922177.sst deleted file mode 100644 index c9130a901a76..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257023922177.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257064292353.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257064292353.sst deleted file mode 100644 index 9f17ec2918f7..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257064292353.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257066815489.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257066815489.sst deleted file mode 100644 index 3436e0d9de62..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257066815489.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257160073219.sst b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257160073219.sst deleted file mode 100644 index 43e0a7f0e8c9..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/doubleDB/data/682219257160073219.sst and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP-CHECKPOINT-CHECKSUM b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP-CHECKPOINT-CHECKSUM deleted file mode 100644 index f3dbd9e7dad1..000000000000 --- a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP-CHECKPOINT-CHECKSUM +++ /dev/null @@ -1 +0,0 @@ -Óìñ \ No newline at end of file diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP-STATISTICS b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP-STATISTICS deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST deleted file mode 100644 index 026bd5b32850..000000000000 Binary files a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST and /dev/null differ diff --git a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST-CHECKSUM b/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST-CHECKSUM deleted file mode 100644 index 77d1b02b0eeb..000000000000 --- a/pkg/ccl/backupccl/testdata/restore_old_versions/exceptional/xDbRef/BACKUP_MANIFEST-CHECKSUM +++ /dev/null @@ -1 +0,0 @@ -óWÁ* \ No newline at end of file