diff --git a/pkg/ccl/backupccl/full_cluster_backup_restore_test.go b/pkg/ccl/backupccl/full_cluster_backup_restore_test.go index 07f4183dd855..7a9a3da9b237 100644 --- a/pkg/ccl/backupccl/full_cluster_backup_restore_test.go +++ b/pkg/ccl/backupccl/full_cluster_backup_restore_test.go @@ -15,6 +15,7 @@ import ( "path/filepath" "strings" "testing" + "time" "github.com/cockroachdb/cockroach/pkg/base" _ "github.com/cockroachdb/cockroach/pkg/ccl/partitionccl" @@ -32,6 +33,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" + "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/errors" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" @@ -144,8 +146,10 @@ CREATE TABLE data2.foo (a int); sqlDB.Exec(t, `GRANT CREATE, SELECT ON DATABASE data TO system_ops;`) sqlDB.Exec(t, `GRANT system_ops TO maxroach1;`) - // Populate system.scheduled_jobs table. - sqlDB.Exec(t, `CREATE SCHEDULE FOR BACKUP data.bank INTO $1 RECURRING '@hourly' FULL BACKUP ALWAYS`, LocalFoo) + // Populate system.scheduled_jobs table with a first run in the future to prevent immediate adoption. + firstRun := timeutil.Now().Add(time.Hour).Format(timeutil.TimestampWithoutTZFormat) + sqlDB.Exec(t, `CREATE SCHEDULE FOR BACKUP data.bank INTO $1 RECURRING '@hourly' FULL BACKUP ALWAYS WITH SCHEDULE OPTIONS first_run = $2`, LocalFoo, firstRun) + sqlDB.Exec(t, `PAUSE SCHEDULES SELECT id FROM [SHOW SCHEDULES FOR BACKUP]`) injectStats(t, sqlDB, "data.bank", "id") sqlDB.Exec(t, `BACKUP TO $1`, LocalFoo)