Skip to content

Commit

Permalink
roachtest: add unsafe_restore_incompatible_version to roachtests
Browse files Browse the repository at this point in the history
Some roachtests rely on fixtures generated before 22.2. To restore
such fixtures that are outside our compatibility window we must run
the restore with `unsafe_restore_incompatible_version`.

Fixes: #98918

Release note: None
  • Loading branch information
adityamaru committed Mar 19, 2023
1 parent ad436a1 commit d9b6fe7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/workloadccl/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ func RestoreFixture(
table := table
g.GoCtx(func(ctx context.Context) error {
start := timeutil.Now()
restoreStmt := fmt.Sprintf(`RESTORE %s.%s FROM $1 WITH into_db=$2`, genName, table.TableName)
restoreStmt := fmt.Sprintf(`RESTORE %s.%s FROM $1 WITH into_db=$2, unsafe_restore_incompatible_version`, genName, table.TableName)
log.Infof(ctx, "Restoring from %s", table.BackupURI)
var rows, index, tableBytes int64
var discard interface{}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/roachtest/tests/schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func registerSchemaChangeDuringKV(r registry.Registry) {
m := c.NewMonitor(ctx, c.All())
m.Go(func(ctx context.Context) error {
t.Status("loading fixture")
if _, err := db.Exec(`RESTORE DATABASE tpch FROM $1`, fixturePath); err != nil {
if _, err := db.Exec(
`RESTORE DATABASE tpch FROM $1 WITH unsafe_restore_incompatible_version`, fixturePath); err != nil {
t.Fatal(err)
}
return nil
Expand Down
10 changes: 8 additions & 2 deletions pkg/cmd/roachtest/tests/sqlsmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func registerSQLSmith(r registry.Registry) {
"seed": sqlsmith.Setups["seed"],
sqlsmith.RandTableSetupName: sqlsmith.Setups[sqlsmith.RandTableSetupName],
"tpch-sf1": func(r *rand.Rand) []string {
return []string{`RESTORE TABLE tpch.* FROM 'gs://cockroach-fixtures/workload/tpch/scalefactor=1/backup?AUTH=implicit' WITH into_db = 'defaultdb';`}
return []string{`
RESTORE TABLE tpch.* FROM 'gs://cockroach-fixtures/workload/tpch/scalefactor=1/backup?AUTH=implicit'
WITH into_db = 'defaultdb', unsafe_restore_incompatible_version;
`}
},
"tpcc": func(r *rand.Rand) []string {
const version = "version=2.1.0,fks=true,interleaved=false,seed=1,warehouses=1"
Expand All @@ -54,7 +57,10 @@ func registerSQLSmith(r registry.Registry) {
} {
stmts = append(
stmts,
fmt.Sprintf("RESTORE TABLE tpcc.%s FROM 'gs://cockroach-fixtures/workload/tpcc/%[2]s/%[1]s?AUTH=implicit' WITH into_db = 'defaultdb';",
fmt.Sprintf(`
RESTORE TABLE tpcc.%s FROM 'gs://cockroach-fixtures/workload/tpcc/%[2]s/%[1]s?AUTH=implicit'
WITH into_db = 'defaultdb', unsafe_restore_incompatible_version;
`,
t, version,
),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/tpc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func loadTPCHDataset(
if _, err := db.ExecContext(ctx, `CREATE DATABASE IF NOT EXISTS tpch;`); err != nil {
return err
}
query := fmt.Sprintf(`RESTORE tpch.* FROM '%s' WITH into_db = 'tpch';`, tpchURL)
query := fmt.Sprintf(`RESTORE tpch.* FROM '%s' WITH into_db = 'tpch', unsafe_restore_incompatible_version;`, tpchURL)
_, err = db.ExecContext(ctx, query)
return err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/roachtest/tests/tpcdsvec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func registerTPCDSVec(r registry.Registry) {
}
t.Status("restoring TPCDS dataset for Scale Factor 1")
if _, err := clusterConn.Exec(
`RESTORE DATABASE tpcds FROM 'gs://cockroach-fixtures/workload/tpcds/scalefactor=1/backup?AUTH=implicit';`,
`
RESTORE DATABASE tpcds FROM 'gs://cockroach-fixtures/workload/tpcds/scalefactor=1/backup?AUTH=implicit'
WITH unsafe_restore_incompatible_version;
`,
); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit d9b6fe7

Please sign in to comment.