Skip to content

Commit e88d431

Browse files
craig[bot]kev-cao
andcommitted
Merge #143452
143452: backup: fix scheduled compaction test flakiness r=msbutler a=kev-cao The scheduled compaction tests were failing because the compaction job is created in a separate transaction *after* the scheduler is notified of the completion of the triggering backup job. The tests were originally immediately looking for the compaction job, causing a failure when no rows were found. Fixes: #143394 Release note: None Co-authored-by: Kevin Cao <[email protected]>
2 parents d26d48c + a82537d commit e88d431

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pkg/backup/backup_compaction_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ func TestScheduledBackupCompaction(t *testing.T) {
428428
defer leaktest.AfterTest(t)()
429429
defer log.Scope(t).Close(t)
430430

431-
skip.WithIssue(t, 143394, "flaky test")
432-
433431
ctx := context.Background()
434432
th, cleanup := newTestHelper(t)
435433
defer cleanup()
@@ -470,10 +468,16 @@ func TestScheduledBackupCompaction(t *testing.T) {
470468
th.waitForSuccessfulScheduledJob(t, inc.ScheduleID())
471469

472470
var jobID jobspb.JobID
473-
th.sqlDB.QueryRow(
474-
t,
475-
`SELECT job_id FROM [SHOW JOBS] WHERE description ILIKE 'COMPACT%' AND job_type = 'BACKUP'`,
476-
).Scan(&jobID)
471+
// The scheduler is notified of the backup job completion and then the
472+
// compaction job is created in a separate transaction. As such, we need to
473+
// poll for the compaction job to be created.
474+
testutils.SucceedsSoon(t, func() error {
475+
return th.sqlDB.DB.QueryRowContext(
476+
ctx,
477+
`SELECT job_id FROM [SHOW JOBS] WHERE description ILIKE 'COMPACT%' AND job_type = 'BACKUP'`,
478+
).Scan(&jobID)
479+
})
480+
477481
testutils.SucceedsSoon(t, func() error {
478482
th.server.JobRegistry().(*jobs.Registry).TestingNudgeAdoptionQueue()
479483
var unused int64

0 commit comments

Comments
 (0)