@@ -15,7 +15,6 @@ import (
1515 "strings"
1616 "sync/atomic"
1717 "testing"
18- "time"
1918
2019 "github.com/cockroachdb/cockroach/pkg/clusterversion"
2120 "github.com/cockroachdb/cockroach/pkg/sql/parser"
@@ -422,10 +421,10 @@ func backupRollbacks(t *testing.T, factory TestServerFactory, cs CumulativeTestC
422421 // Fetch the state of the cluster before the schema change kicks off.
423422 tdb .Exec (t , fmt .Sprintf ("USE %q" , cs .DatabaseName ))
424423 expected := parserRoundTrip (t , tdb .QueryStr (t , fetchDescriptorStateQuery ))
425- // Store the start time , so we know which jobs are relevant.
426- ts := tdb .QueryRow (t , "SELECT current_timestamp(0)::timestamp " )
427- var startTime time. Time
428- ts .Scan (& startTime )
424+ // Store the highest job ID , so we know which jobs are relevant.
425+ jobID := tdb .QueryRow (t , "SELECT COALESCE(max(job_id), 0) FROM [SHOW JOBS] " )
426+ var maxJobID int64
427+ jobID .Scan (& maxJobID )
429428 // Kick off the schema change, fail it at the prescribed stage,
430429 // and perform the backups during the rollback via the BeforeStage hook.
431430 require .Regexp (t , fmt .Sprintf ("boom %d" , cs .StageOrdinal ),
@@ -437,7 +436,7 @@ func backupRollbacks(t *testing.T, factory TestServerFactory, cs CumulativeTestC
437436 // Note: Depending on the state of the schema objects, no job may be created
438437 // to finalize the rollback, since dependent objects were never backed
439438 // up.
440- succeeded , jobExists := hasLatestSchemaChangeSucceededWithTimestamp (t , tdb , startTime )
439+ succeeded , jobExists := hasLatestSchemaChangeSucceededWithMaxJobID (t , tdb , maxJobID )
441440 require .False (t , succeeded && jobExists )
442441 tdb .Exec (t , fmt .Sprintf ("USE %q" , cs .DatabaseName ))
443442 postRollback := parserRoundTrip (t , tdb .QueryStr (t , fetchDescriptorStateQuery ))
@@ -579,10 +578,11 @@ func exerciseBackupRestore(
579578 tdb .Exec (t , cs .CreateDatabaseStmt )
580579 }
581580
582- // Store the start time, so we know which jobs are relevant.
583- ts := tdb .QueryRow (t , "SELECT current_timestamp(0)::timestamp" )
584- var startTime time.Time
585- ts .Scan (& startTime )
581+ // Store the highest job ID, so we know which jobs are relevant.
582+ tdb .Exec (t , "USE system" )
583+ jobID := tdb .QueryRow (t , "SELECT COALESCE(max(job_id), 0) FROM [SHOW JOBS]" )
584+ var maxJobID int64
585+ jobID .Scan (& maxJobID )
586586
587587 // RESTORE.
588588 pe .RequestPlan ()
@@ -598,7 +598,7 @@ func exerciseBackupRestore(
598598 skipComparison := false
599599 // If the only thing left is to clean up then this restore may have no
600600 // job so the startTime is important.
601- if succeeded , jobExists := hasLatestSchemaChangeSucceededWithTimestamp (t , tdb , startTime ); (succeeded && jobExists ) || (b .maySucceed && ! jobExists ) {
601+ if succeeded , jobExists := hasLatestSchemaChangeSucceededWithMaxJobID (t , tdb , maxJobID ); (succeeded && jobExists ) || (b .maySucceed && ! jobExists ) {
602602 expected = b .expectedOnSuccess
603603 skipComparison = b .skipComparisonOnSuccess
604604 if ! b .maySucceed {
0 commit comments