Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
541 stars 416 forks source link

[Bug]: #2788

Closed rflitcroft closed 2 months ago

rflitcroft commented 4 months ago

Terraform CLI Version

1.8.2

Terraform Provider Version

0.90.0

Terraform Configuration

provider "snowflake" {
  account                           = "${var.snowflake_account}.${var.snowflake_region}"
  role                              = "ACCOUNTADMIN"
  authenticator                     = "ExternalBrowser"
  client_store_temporary_credential = true
}

Category

category:provider_config

Object type(s)

No response

Expected Behavior

Terraform apply completes without crashing

Actual Behavior

Terraform apply crashed

Steps to Reproduce

run "terraform apply"

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

Stack trace from the terraform-provider-snowflake_v0.90.0 plugin:

fatal error: concurrent map writes

goroutine 44 [running]: reflect.mapassign_faststr0(0x1deaa40, 0x1d37020?, {0xc00122a270?, 0x2496a30?}, 0x1d37020?) runtime/map.go:1376 +0x25 reflect.mapassign_faststr(0x1d37020?, 0xc001283f60?, {0xc00122a270, 0x28}, 0x19?) reflect/value.go:3837 +0xa9 reflect.Value.SetMapIndex({0x1deaa40?, 0x3478c30?, 0x1fe?}, {0x1d37020, 0xc001283f70, 0x98}, {0x1d37020, 0xc001283f60, 0x198}) reflect/value.go:2402 +0x225 encoding/json.(decodeState).object(0xc00102c480, {0x1d00040?, 0x3478c30?, 0xc000fda4e0?}) encoding/json/decode.go:797 +0x13c5 encoding/json.(decodeState).value(0xc00102c480, {0x1d00040?, 0x3478c30?, 0x799eaa8bc878?}) encoding/json/decode.go:374 +0x3e encoding/json.(decodeState).unmarshal(0xc00102c480, {0x1d00040?, 0x3478c30?}) encoding/json/decode.go:181 +0x133 encoding/json.Unmarshal({0xc000140200, 0x1c4, 0x200}, {0x1d00040, 0x3478c30}) encoding/json/decode.go:108 +0x111 github.com/snowflakedb/gosnowflake.readTemporaryCacheFile() github.com/snowflakedb/gosnowflake@v1.7.1/secure_storage_manager.go:230 +0xd4 github.com/snowflakedb/gosnowflake.readTemporaryCredential(0x799e639fca40?, {0x20b4ce6?, 0x40?}) github.com/snowflakedb/gosnowflake@v1.7.1/secure_storage_manager.go:179 +0x7c github.com/snowflakedb/gosnowflake.getCredential(0xc000fda480, {0x20b4ce6, 0x8}) github.com/snowflakedb/gosnowflake@v1.7.1/secure_storagemanager.go:135 +0x3a github.com/snowflakedb/gosnowflake.fillCachedIDToken(...) github.com/snowflakedb/gosnowflake@v1.7.1/auth.go:562 github.com/snowflakedb/gosnowflake.authenticateWithConfig(0xc000fda480) github.com/snowflakedb/gosnowflake@v1.7.1/auth.go:502 +0x4b github.com/snowflakedb/gosnowflake.SnowflakeDriver.OpenWithConfig({}, {, _}, {{0xc00068e25a, 0x7}, {0xc000652408, 0x16}, {0xc00068e240, 0x0}, {0x0, ...}, ...}) github.com/snowflakedb/gosnowflake@v1.7.1/driver.go:43 +0x148 github.com/snowflakedb/gosnowflake.SnowflakeDriver.Open({}, {0xc00068e240, 0x105}) github.com/snowflakedb/gosnowflake@v1.7.1/driver.go:26 +0x112 github.com/luna-duclos/instrumentedsql.dsnConnector.Connect(...) github.com/luna-duclos/instrumentedsql@v1.1.3/connector.go:53 github.com/luna-duclos/instrumentedsql.wrappedConnector.Connect({{{0x2445f20, 0x21bf880}, {0x2448640, 0x34b03e0}, 0x0, 0x0}, {0x244df98, 0xc000631a60}, 0xc0006a4ec0}, {0x245e728, ...}) github.com/luna-duclos/instrumentedsql@v1.1.3/connector.go:33 +0x1ec database/sql.(DB).conn(0xc00067b1e0, {0x245e728, 0xc000fdfdd0}, 0x1) database/sql/sql.go:1387 +0x717 database/sql.(DB).query(0x40?, {0x245e728, 0xc000fdfdd0}, {0xc00122a210, 0x22}, {0x0, 0x0, 0x0}, 0x40?) database/sql/sql.go:1721 +0x57 database/sql.(DB).QueryContext.func1(0x88?) database/sql/sql.go:1704 +0x4f database/sql.(DB).retry(0x0?, 0xc00094ad38) database/sql/sql.go:1538 +0x42 database/sql.(DB).QueryContext(0xc00094ae50?, {0x245e728?, 0xc000fdfdd0?}, {0xc00122a210?, 0x30?}, {0x0?, 0x1f9d480?, 0xc00094ae90?}) database/sql/sql.go:1703 +0xc5 github.com/jmoiron/sqlx.(DB).QueryxContext(0xc000ff8690, {0x245e728?, 0xc000fdfdd0?}, {0xc00122a210?, 0x1f9d480?}, {0x0?, 0xc00094ae78?, 0x49ccc6?}) github.com/jmoiron/sqlx@v1.3.5/sqlx_context.go:161 +0x3c github.com/jmoiron/sqlx.SelectContext({0x245e728?, 0xc000fdfdd0?}, {0x2458310?, 0xc000ff8690?}, {0x1d07be0, 0xc000638888}, {0xc00122a210?, 0x18?}, {0x0, 0x0, ...}) github.com/jmoiron/sqlx@v1.3.5/sqlx_context.go:55 +0x89 github.com/jmoiron/sqlx.(DB).SelectContext(...) github.com/jmoiron/sqlx@v1.3.5/sqlx_context.go:140 github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.(Client).query(0xc0008cd500, {0x245e6f0, 0x34b03e0}, {0x1d07be0, 0xc000638888}, {0xc00122a210, 0x22}) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/client.go:287 +0x23b github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.validateAndQuery[...](0xc00094afc8, {0x245e6f0?, 0x34b03e0}, {0x2445dc0, 0xc000c52480}) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/helpers_proposal.go:37 +0xc9 github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.(databases).Show(0x0?, {0x245e6f0?, 0x34b03e0?}, 0x0?) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/databases.go:571 +0x79 github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk.(databases).ShowByID(0xc00088e400, {0x245e6f0, 0x34b03e0}, {{0xc000c382b0?, 0x0?}}) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/databases.go:580 +0xfc github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadDatabase(0xc001218400, {0x1cda940?, 0xc0006ae070?}) github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/database.go:199 +0x13c github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).read(0x245e728?, {0x245e728?, 0xc000fdf410?}, 0xd?, {0x1cda940?, 0xc0006ae070?}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:783 +0x163 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).RefreshWithoutUpgrade(0xc000d58fc0, {0x245e728, 0xc000fdf410}, 0xc00107e680, {0x1cda940, 0xc0006ae070}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:1089 +0x552 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ReadResource(0xc000c7c810, {0x245e728?, 0xc000fdf2c0?}, 0xc000c52300) github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:663 +0x48a github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x24745c0?, 0xc000c7c810?}}, {0x245e728?, 0xc000fdf2c0?}, 0xc000c52140?) github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:176 +0x225 github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(muxServer).ReadResource(0x245e760?, {0x245e728?, 0xc000fdefc0?}, 0xc000c52140) github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ReadResource.go:35 +0x193 github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(server).ReadResource(0xc000a280a0, {0x245e728?, 0xc000fde120?}, 0xc000fda240) github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:787 +0x48b github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x202eea0?, 0xc000a280a0}, {0x245e728, 0xc000fde120}, 0xc001218000, 0x0) github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x169 google.golang.org/grpc.(Server).processUnaryRPC(0xc0000fad20, {0x245e728, 0xc000fde000}, {0x246f840, 0xc0002491e0}, 0xc00144ad80, 0xc000632300, 0x346c028, 0x0) google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03 google.golang.org/grpc.(Server).handleStream(0xc0000fad20, {0x246f840, 0xc0002491e0}, 0xc00144ad80) google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec google.golang.org/grpc.(Server).serveStreams.func2.1() google.golang.org/grpc@v1.60.0/server.go:1016 +0x59 created by google.golang.org/grpc.(Server).serveStreams.func2 in goroutine 28 google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

goroutine 1 [select]: github.com/hashicorp/go-plugin.Serve(0xc000bb9bc0) github.com/hashicorp/go-plugin@v1.6.0/server.go:503 +0x1739 github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.Serve({0x2121209, 0x2e}, 0xc000d4ceb0, {0x0, 0x0, 0x0}) github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:315 +0xbaf main.main() github.com/Snowflake-Labs/terraform-provider-snowflake/main.go:54 +0x285

goroutine 14 [IO wait]: internal/poll.runtime_pollWait(0x799e63cfb068, 0x72) runtime/netpoll.go:343 +0x85 internal/poll.(pollDesc).wait(0xc0005e2680?, 0xc0006343f0?, 0x0) internal/poll/fd_poll_runtime.go:84 +0x27 internal/poll.(pollDesc).waitRead(...) internal/poll/fd_poll_runtime.go:89 internal/poll.(*FD).ReadMsg(0xc0005e2680, {0xc0006343f0, 0x10, 0x10}, {0xc000025320, 0x1000, 0x1000}, 0x3499960?) internal/poll/fd_unix.go:301 +0x38a

Error: The terraform-provider-snowflake_v0.90.0 plugin crashed!

Would you like to implement a fix?

sfc-gh-jcieslak commented 4 months ago

Hey @rflitcroft Please refer to this issue. The fix was recently provided in the latest gosnowflake driver version. For now, please try to use the workaround provided in the linked issue.

sfc-gh-asawicki commented 4 months ago

Hey @rflitcroft, we released v0.91.0 yesterday with the bumped version of the underlying gosnowflake driver. Please upgrade to the newest version and let us know if this fixes your issues.

sfc-gh-jcieslak commented 2 months ago

Closing due to long inactivity. In case the error still persists report a new gh issue. Thank You.