Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backupccl: deflake TestDataDriven_restore_on_fail_or_cancel_retry #119342

Merged
merged 1 commit into from
Mar 11, 2024
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
18 changes: 13 additions & 5 deletions pkg/ccl/backupccl/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ func (d *datadrivenTestState) getIODir(t *testing.T, name string) string {
return dir
}

func (d *datadrivenTestState) clearConnCache() {
for _, db := range d.sqlDBs {
db.Close()
}
d.sqlDBs = make(map[sqlDBKey]*gosql.DB)
}

func (d *datadrivenTestState) getSQLDB(t *testing.T, name string, user string) *gosql.DB {
return d.getSQLDBForVC(t, name, "default", user)
}
Expand Down Expand Up @@ -462,14 +469,13 @@ func runTestDataDriven(t *testing.T, testFilePathFromWorkspace string) {
ds.noticeBuffer = nil
const user = "root"
sqlDB := ds.getSQLDB(t, lastCreatedCluster, user)
// First, run the schema change.

_, err := sqlDB.Exec(d.Input)

var jobID jobspb.JobID
{
const qFmt = `SELECT job_id FROM [SHOW JOBS] WHERE job_type = '%s' ORDER BY created DESC LIMIT 1`
errJob := sqlDB.QueryRow(fmt.Sprintf(qFmt, jobType)).Scan(&jobID)
const query = `SELECT id FROM system.jobs WHERE job_type = $1 ORDER BY created DESC LIMIT 1`
errJob := sqlDB.QueryRow(query, jobType.String()).Scan(&jobID)
if !errors.Is(errJob, gosql.ErrNoRows) {
require.NoError(t, errJob)
}
Expand Down Expand Up @@ -520,7 +526,9 @@ func runTestDataDriven(t *testing.T, testFilePathFromWorkspace string) {
ds.cleanup(ctx, t)
ds = newDatadrivenTestState()
return ""

case "clear-conn-cache":
ds.clearConnCache()
return ""
case "new-cluster":
var name, shareDirWith, iodir, localities, beforeVersion, testingKnobCfg string
var splits int
Expand Down Expand Up @@ -641,7 +649,7 @@ func runTestDataDriven(t *testing.T, testFilePathFromWorkspace string) {
var jobID jobspb.JobID
require.NoError(t,
ds.getSQLDB(t, cluster, user).QueryRow(
`SELECT job_id FROM [SHOW JOBS] ORDER BY created DESC LIMIT 1`).Scan(&jobID))
`SELECT id FROM system.jobs ORDER BY created DESC LIMIT 1`).Scan(&jobID))
fmt.Printf("expecting pausepoint, found job ID %d\n\n\n", jobID)

runner := sqlutils.MakeSQLRunner(ds.getSQLDB(t, cluster, user))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ RESTORE FROM LATEST IN 'nodelocal://1/cluster_backup';
----
job paused at pausepoint

clear-conn-cache
----

exec-sql
SET CLUSTER SETTING jobs.debug.pausepoints = '';
----
Expand Down
Loading