Skip to content

Commit

Permalink
catalog/lease: deflake TestDescriptorRefreshOnRetry
Browse files Browse the repository at this point in the history
The test was flaky since the background thread to refresh leases could
run and cause the acquisition counts to be off.

Release note: None
  • Loading branch information
rafiss committed Dec 9, 2024
1 parent ccaed97 commit 67b1c9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/sql/catalog/lease/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ go_test(
"//pkg/sql/sqlliveness",
"//pkg/sql/sqlliveness/slbase",
"//pkg/sql/sqlliveness/slprovider",
"//pkg/sql/stats",
"//pkg/sql/types",
"//pkg/storage",
"//pkg/testutils",
Expand Down
13 changes: 8 additions & 5 deletions pkg/sql/catalog/lease/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sqlinstance/instancestorage"
"github.com/cockroachdb/cockroach/pkg/sql/sqlliveness/slbase"
"github.com/cockroachdb/cockroach/pkg/sql/sqlliveness/slprovider"
"github.com/cockroachdb/cockroach/pkg/sql/stats"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
Expand Down Expand Up @@ -949,14 +950,16 @@ func TestDescriptorRefreshOnRetry(t *testing.T) {
},
},
}
params.Settings = cluster.MakeTestingClusterSettings()
// Disable the automatic stats collection, which could interfere with
// the lease acquisition counts in this test.
stats.AutomaticStatisticsClusterMode.Override(ctx, &params.Settings.SV, false)
// Set a long lease duration so that the periodic task to refresh leases does
// not run.
lease.LeaseDuration.Override(ctx, &params.Settings.SV, 24*time.Hour)
srv, sqlDB, kvDB := serverutils.StartServer(t, params)
defer srv.Stopper().Stop(context.Background())
s := srv.ApplicationLayer()
// Disable the automatic stats collection, which could interfere with
// the lease acquisition counts in this test.
if _, err := sqlDB.Exec("SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false"); err != nil {
t.Fatal(err)
}
if _, err := sqlDB.Exec(`
CREATE DATABASE t;
CREATE TABLE t.foo (v INT);
Expand Down

0 comments on commit 67b1c9c

Please sign in to comment.