From 27b5e09b473ad527aa88430bf899e632b4948674 Mon Sep 17 00:00:00 2001 From: Andy Yang Date: Tue, 19 Sep 2023 18:50:59 +0000 Subject: [PATCH] gcjob_test: add more logging to TestGCJobRetry This patch adds more logging to `TestGCJobRetry` to help debug occasional flakes. Release note: None --- pkg/sql/gcjob_test/gc_job_test.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pkg/sql/gcjob_test/gc_job_test.go b/pkg/sql/gcjob_test/gc_job_test.go index 3c36498d5fbd..3794f97a84e2 100644 --- a/pkg/sql/gcjob_test/gc_job_test.go +++ b/pkg/sql/gcjob_test/gc_job_test.go @@ -306,10 +306,25 @@ SELECT job_id FROM [SHOW JOBS] WHERE job_type = 'SCHEMA CHANGE GC' AND description LIKE '%foo%';`, ).Scan(&jobID) - tdb.CheckQueryResultsRetry(t, - "SELECT running_status FROM crdb_internal.jobs WHERE job_id = "+jobID, - [][]string{{string(sql.RunningStatusWaitingForMVCCGC)}}, - ) + + const expectedRunningStatus = string(sql.RunningStatusWaitingForMVCCGC) + testutils.SucceedsSoon(t, func() error { + var status, runningStatus, lastRun, nextRun, numRuns, jobErr string + tdb.QueryRow(t, fmt.Sprintf(` +SELECT status, running_status, error, last_run, next_run, num_runs +FROM crdb_internal.jobs +WHERE job_id = %s`, jobID)).Scan(&status, &runningStatus, &jobErr, &lastRun, &nextRun, &numRuns) + + t.Logf(`details about SCHEMA CHANGE GC job: {status: %q, running_status: %q, error: %q, last_run: %q, next_run: %q, num_runs: %q}`, + status, runningStatus, jobErr, lastRun, nextRun, numRuns) + + if runningStatus != expectedRunningStatus { + return errors.Newf(`running_status %s does not match expected status %s`, + runningStatus, expectedRunningStatus) + } + + return nil + }) } // TestGCTenant is lightweight test that tests the branching logic in Resume