Skip to content

Commit

Permalink
ccl/schemachangerccl: deflake TestBackupSuccess
Browse files Browse the repository at this point in the history
Previously, the backup and restore tests for the declarative schema
changer could flake because the latest completed schema job could not be
sufficiently determined by the finish_time. This was because this time
only has resolution of seconds at most, so multiple jobs could have the
same finish time. To address this, this patch also sorts the jobs by
job_id as well, which should be increasing for later jobs.

Fixes: cockroachdb#131583

Release note: None
  • Loading branch information
fqazi authored and sambhav-jain-16 committed Nov 20, 2024
1 parent 6cbda2e commit 4fb3b64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sql/schemachanger/sctest/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func waitForSchemaChangesToFinish(t *testing.T, tdb *sqlutils.SQLRunner) {

func hasLatestSchemaChangeSucceeded(t *testing.T, tdb *sqlutils.SQLRunner) bool {
result := tdb.QueryStr(t, fmt.Sprintf(
`SELECT status FROM [SHOW JOBS] WHERE job_type IN ('%s') ORDER BY finished DESC LIMIT 1`,
`SELECT status FROM [SHOW JOBS] WHERE job_type IN ('%s') ORDER BY finished DESC, job_id DESC LIMIT 1`,
jobspb.TypeNewSchemaChange,
))
return result[0][0] == "succeeded"
Expand Down

0 comments on commit 4fb3b64

Please sign in to comment.