Skip to content

Commit

Permalink
sqlccl: deflake TestGCTenantJobWaitsForProtectedTimestamps
Browse files Browse the repository at this point in the history
The tenant server must be shut down before the tenant record is
removed; otherwise the tenant's SQL server will self-terminate
by calling Stop() on its stopper, which in this case was shared with
the parent cluster.

Release note: None

Co-authored-by: Arul Ajmani <[email protected]>
Co-authored-by: adityamaru <[email protected]>
  • Loading branch information
3 people committed Apr 3, 2023
1 parent 6a3422b commit 58c54d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/ccl/testccl/sqlccl/tenant_gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
Expand Down Expand Up @@ -470,7 +471,7 @@ func TestGCTableOrIndexWaitsForProtectedTimestamps(t *testing.T) {
func TestGCTenantJobWaitsForProtectedTimestamps(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
skip.WithIssue(t, 94808)

defer gcjob.SetSmallMaxGCIntervalForTest()()

ctx := context.Background()
Expand Down Expand Up @@ -614,8 +615,11 @@ func TestGCTenantJobWaitsForProtectedTimestamps(t *testing.T) {
tenID := roachpb.MustMakeTenantID(10)
sqlDB.Exec(t, "ALTER RANGE tenants CONFIGURE ZONE USING gc.ttlseconds = 1;")

tenantStopper := stop.NewStopper()
defer tenantStopper.Stop(ctx) // in case the test fails prematurely.

ten, conn10 := serverutils.StartTenant(t, srv,
base.TestTenantArgs{TenantID: tenID, Stopper: srv.Stopper()})
base.TestTenantArgs{TenantID: tenID, Stopper: tenantStopper})
defer conn10.Close()

// Write a cluster PTS record as the tenant.
Expand All @@ -630,6 +634,10 @@ func TestGCTenantJobWaitsForProtectedTimestamps(t *testing.T) {
return tenPtp.WithTxn(txn).Protect(ctx, rec)
}))

// Ensure the secondary tenant is not running any more tasks.
tenantStopper.Stop(ctx)

// Drop the record.
sqlDB.Exec(t, `DROP TENANT [$1]`, tenID.ToUint64())

sqlDB.CheckQueryResultsRetry(
Expand Down

0 comments on commit 58c54d9

Please sign in to comment.