Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/backup/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func restoreWithRetry(
return roachpb.RowCount{}, jobs.MarkAsPermanentJobError(err)
}

if jobs.IsPauseSelfError(err) {
return roachpb.RowCount{}, err
}

// If we are draining, it is unlikely we can start a
// new DistSQL flow. Exit with a retryable error so
// that another node can pick up the job.
Expand Down
46 changes: 46 additions & 0 deletions pkg/backup/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/backup/backuptestutils"
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/cloud/nodelocal"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/sql"
Expand Down Expand Up @@ -538,3 +539,48 @@ func TestRestoreRevisionHistoryWithCompactions(t *testing.T) {
}
})
}

func TestRestorePausepointSkipsRetries(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

tmpDir := t.TempDir()
defer nodelocal.ReplaceNodeLocalForTesting(tmpDir)()

mu := struct {
syncutil.Mutex
attemptCount int
}{}
testKnobs := &sql.BackupRestoreTestingKnobs{
RunBeforeRestoreFlow: func() error {
mu.Lock()
defer mu.Unlock()
mu.attemptCount++
return nil
},
}
var params base.TestClusterArgs
params.ServerArgs.Knobs.BackupRestore = testKnobs

const numAccounts = 10
_, sqlDB, _, cleanupFn := backuptestutils.StartBackupRestoreTestCluster(
t, singleNode, backuptestutils.WithParams(params), backuptestutils.WithBank(numAccounts),
)
defer cleanupFn()

sqlDB.Exec(t, "SET CLUSTER SETTING jobs.debug.pausepoints = 'restore.before_link'")
sqlDB.Exec(t, "BACKUP DATABASE data INTO 'nodelocal://1/backup'")

sqlDB.ExpectErr(
t,
"pause point",
`RESTORE DATABASE data FROM LATEST IN 'nodelocal://1/backup'
WITH experimental deferred copy, new_db_name = 'restored'`,
)

mu.Lock()
defer mu.Unlock()
require.Equal(
t, 1, mu.attemptCount, "expected only 1 restore attempt since pausepoint should skip retries",
)
}