terraform-plugin-sdk icon indicating copy to clipboard operation
terraform-plugin-sdk copied to clipboard

helper/resource: Potential Goroutine Leak with go-plugin

Open bflad opened this issue 3 years ago • 0 comments

SDK version

v2.23.0

Relevant provider source code

Refer to the terraform-provider-random acceptance testing.

Debug Output

Go timeout panic stacktrace

Expected Behavior

Running go test -count=1 -parallel=1 -timeout=10m -v ./internal/provider would yield a relatively small number of go-plugin-related Goroutines because the testing should be serialized and each test should properly close them.

Actual Behavior

Refer to Gist above, there's a lot of this:

goroutine 10 [select, 9 minutes]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x0?)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:121 +0x58
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0x14000046460)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:411 +0x40
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_server.go:85 +0x424

goroutine 75981 [select]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x1005ab701?)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:121 +0x58
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0x140002b2370)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:411 +0x40
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_server.go:85 +0x424

goroutine 5016 [chan receive, 8 minutes]:
testing.(*testContext).waitParallel(0x14000127e50)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1557 +0x15c
testing.(*T).Parallel(0x140001d1a00)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1272 +0x18c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.ParallelTest({0x105717818, 0x140001d1a00}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
	/Users/bflad/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/testing.go:652 +0x40
github.com/terraform-providers/terraform-provider-random/internal/provider.TestAccResourcePassword_Keepers_Replace_NullValueToValue(0x140006e8160?)
	/Users/bflad/src/github.com/hashicorp/terraform-provider-random/internal/provider/resource_password_test.go:2147 +0x3c4
testing.tRunner(0x140001d1a00, 0x105701d40)
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1446 +0x10c
created by testing.(*T).Run
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/testing/testing.go:1493 +0x300

goroutine 45613 [select, 5 minutes]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x140002429a0?)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:121 +0x58
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0x14000167810)
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_broker.go:411 +0x40
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
	/Users/bflad/go/pkg/mod/github.com/hashicorp/[email protected]/grpc_server.go:85 +0x424

Steps to Reproduce

  1. In terraform-provider-random TF_ACC=1 go test -count=1 -parallel=1 -timeout=10m -v ./internal/provider (and have it time out so it raises the stacktrace)

bflad avatar Sep 20 '22 13:09 bflad