From 17b71595b45c808b09ac5008d06aca6c629f4d86 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Sat, 9 Nov 2024 05:14:56 +0000 Subject: [PATCH] lease: dump stacks if test fails We added additional logging to help debug a source of flakiness in which the acquisition counts exceed the number of release counts. For that logging to be useful, we need to know the goroutine IDs and stacks. Release note: None --- pkg/sql/catalog/lease/BUILD.bazel | 1 + pkg/sql/catalog/lease/lease_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/sql/catalog/lease/BUILD.bazel b/pkg/sql/catalog/lease/BUILD.bazel index 820ef1d67299..f46155ff28c2 100644 --- a/pkg/sql/catalog/lease/BUILD.bazel +++ b/pkg/sql/catalog/lease/BUILD.bazel @@ -142,6 +142,7 @@ go_test( "//pkg/testutils/sqlutils", "//pkg/testutils/testcluster", "//pkg/util/admission", + "//pkg/util/allstacks", "//pkg/util/ctxgroup", "//pkg/util/encoding", "//pkg/util/hlc", diff --git a/pkg/sql/catalog/lease/lease_test.go b/pkg/sql/catalog/lease/lease_test.go index 4bebd8e04de4..6c1cd5e7e3be 100644 --- a/pkg/sql/catalog/lease/lease_test.go +++ b/pkg/sql/catalog/lease/lease_test.go @@ -62,6 +62,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/util/allstacks" "github.com/cockroachdb/cockroach/pkg/util/ctxgroup" "github.com/cockroachdb/cockroach/pkg/util/encoding" "github.com/cockroachdb/cockroach/pkg/util/hlc" @@ -989,6 +990,7 @@ CREATE TABLE t.foo (v INT); // Descriptor has been acquired one more time than it has been released. aCount, rCount := atomic.LoadInt32(&fooAcquiredCount), atomic.LoadInt32(&fooReleaseCount) if aCount != rCount+1 { + t.Logf("\nall stacks:\n\n%s\n", allstacks.Get()) t.Fatalf("invalid descriptor acquisition counts = %d, %d", aCount, rCount) }