Skip to content

Commit

Permalink
backupccl: deflake TestGCDropIndexSpanExpansion
Browse files Browse the repository at this point in the history
With cockroachdb#73876 there is a bit more asynchrony than before and
thus the test must wait until all the ranges have completed splitting
before it attempts the last backup, so that the ExportRequest targets
the range with the correct SpanConfig applied to it.

Fixes: cockroachdb#75202

Release note: None
  • Loading branch information
adityamaru committed Jan 25, 2022
1 parent dc07599 commit 69cf0d4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9007,11 +9007,12 @@ func TestGCDropIndexSpanExpansion(t *testing.T) {
}})
defer tc.Stopper().Stop(ctx)
sqlRunner := sqlutils.MakeSQLRunner(tc.Conns[0])
sqlRunner.Exec(t, `SET CLUSTER SETTING kv.closed_timestamp.target_duration = '100ms'`) // speeds up the test

sqlRunner.Exec(t, `
CREATE DATABASE test; USE test;
CREATE TABLE foo (id INT PRIMARY KEY, id2 INT, id3 INT, INDEX bar (id2), INDEX baz(id3));
ALTER TABLE foo CONFIGURE ZONE USING gc.ttlseconds = '1';
ALTER INDEX foo@bar CONFIGURE ZONE USING gc.ttlseconds = '1';
INSERT INTO foo VALUES (1, 2, 3);
DROP INDEX foo@bar;
`)
Expand All @@ -9033,6 +9034,25 @@ DROP INDEX foo@bar;
// Wait for the GC to complete.
jobutils.WaitForJob(t, sqlRunner, gcJobID)

waitForTableSplit := func() {
testutils.SucceedsSoon(t, func() error {
count := 0
sqlRunner.QueryRow(t,
"SELECT count(*) "+
"FROM crdb_internal.ranges_no_leases "+
"WHERE table_name = $1 "+
"AND database_name = $2",
"foo", "test").Scan(&count)
if count == 0 {
return errors.New("waiting for table split")
}
return nil
})
}
waitForTableSplit()

// This backup should succeed since the spans being backed up have a default
// GC TTL of 25 hours.
sqlRunner.Exec(t, `BACKUP INTO LATEST IN 'nodelocal://0/foo' WITH revision_history`)
}

Expand Down

0 comments on commit 69cf0d4

Please sign in to comment.