diff --git a/pkg/ccl/backupccl/full_cluster_backup_restore_test.go b/pkg/ccl/backupccl/full_cluster_backup_restore_test.go index 89736c7a078e..149f8fc1154e 100644 --- a/pkg/ccl/backupccl/full_cluster_backup_restore_test.go +++ b/pkg/ccl/backupccl/full_cluster_backup_restore_test.go @@ -239,7 +239,6 @@ CREATE TABLE data2.foo (a int); systemschema.TableStatisticsTable.GetName(), systemschema.UITable.GetName(), systemschema.UsersTable.GetName(), - systemschema.ZonesTable.GetName(), systemschema.ScheduledJobsTable.GetName(), } @@ -315,6 +314,22 @@ CREATE TABLE data2.foo (a int); } }) + t.Run("zone_configs", func(t *testing.T) { + // The restored zones should be a superset of the zones in the backed up + // cluster. + zoneIDsResult := sqlDB.QueryStr(t, `SELECT id FROM system.zones`) + var q strings.Builder + q.WriteString("SELECT * FROM system.zones WHERE id IN (") + for i, restoreZoneIDRow := range zoneIDsResult { + if i > 0 { + q.WriteString(", ") + } + q.WriteString(restoreZoneIDRow[0]) + } + q.WriteString(")") + sqlDBRestore.CheckQueryResults(t, q.String(), sqlDB.QueryStr(t, q.String())) + }) + t.Run("ensure that tables can be created at the excepted ID", func(t *testing.T) { var maxID, dbID, tableID int sqlDBRestore.QueryRow(t, "SELECT max(id) FROM system.namespace").Scan(&maxID) diff --git a/pkg/ccl/backupccl/restore_job.go b/pkg/ccl/backupccl/restore_job.go index 20ebf102d78b..8ec40b75d4ab 100644 --- a/pkg/ccl/backupccl/restore_job.go +++ b/pkg/ccl/backupccl/restore_job.go @@ -2523,9 +2523,12 @@ func (r *restoreResumer) cleanupTempSystemTables(ctx context.Context) error { executor := r.execCfg.InternalExecutor // After restoring the system tables, drop the temporary database holding the // system tables. + gcTTLQuery := fmt.Sprintf("ALTER DATABASE %s CONFIGURE ZONE USING gc.ttlseconds=1", restoreTempSystemDB) + if _, err := executor.Exec(ctx, "altering-gc-ttl-temp-system" /* opName */, nil /* txn */, gcTTLQuery); err != nil { + log.Errorf(ctx, "failed to update the GC TTL of %q: %+v", restoreTempSystemDB, err) + } dropTableQuery := fmt.Sprintf("DROP DATABASE %s CASCADE", restoreTempSystemDB) - _, err := executor.Exec(ctx, "drop-temp-system-db" /* opName */, nil /* txn */, dropTableQuery) - if err != nil { + if _, err := executor.Exec(ctx, "drop-temp-system-db" /* opName */, nil /* txn */, dropTableQuery); err != nil { return errors.Wrap(err, "dropping temporary system db") } return nil