-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
terraform-plugin-log version
% go list -m github.com/hashicorp/terraform-plugin-log/...
github.com/hashicorp/terraform-plugin-log v0.7.0
Relates hashicorp/terraform-provider-aws#29236.
With v4.53.0, released 02/02/2023, the Terraform AWS Provider has started to use terraform-plugin-log
(via aws-sdk-go-base
) to log AWS SDK for Go requests and responses.
Under heavy usage we are seeing crashes:
fatal error: concurrent map writes
goroutine 1730 [running]:
github.com/hashicorp/terraform-plugin-log/tflog.SetField.func1(...)
github.com/hashicorp/[email protected]/internal/logging/options.go:212
github.com/hashicorp/terraform-plugin-log/tflog.SetField({0xe25bd00, 0xc001d5f890}, {0xce4900e, 0xb}, {0xa619820?, 0xc00089eb90})
github.com/hashicorp/[email protected]/tflog/provider.go:18 +0x111
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2.setAWSFields({0xe25bd00?, 0xc003bc12f0?}, 0xc005cbaa00)
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/[email protected]/logger.go:40 +0x9c
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2.logRequest(0xc005cbaa00)
github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/[email protected]/logger.go:69 +0x5f
...
terraform-plugin-log/internal/logging/options.go
Lines 205 to 215 in 2a7a4a8
func WithField(key string, value interface{}) Option { | |
return func(l LoggerOpts) LoggerOpts { | |
// Lazily create this map, on first assignment | |
if l.Fields == nil { | |
l.Fields = make(map[string]interface{}) | |
} | |
l.Fields[key] = value | |
return l | |
} | |
} |
terraform-plugin-log/tflog/provider.go
Lines 15 to 21 in 2a7a4a8
func SetField(ctx context.Context, key string, value interface{}) context.Context { | |
lOpts := logging.GetProviderRootTFLoggerOpts(ctx) | |
lOpts = logging.WithField(key, value)(lOpts) | |
return logging.SetProviderRootTFLoggerOpts(ctx, lOpts) | |
} |
https://github.com/hashicorp/aws-sdk-go-base/blob/f0b32e1671652e7f19ebd715676fceb7c37190f2/v2/awsv1shim/logger.go#L38-L51
It is not clear which component is responsible for ensuring goroutine-safety here.
lukedd
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working