Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory write races when using logger metadata #65

Open
paramite opened this issue Jul 12, 2021 · 0 comments
Open

Memory write races when using logger metadata #65

paramite opened this issue Jul 12, 2021 · 0 comments

Comments

@paramite
Copy link
Member

paramite commented Jul 12, 2021

Using single logger in the whole application is not a good idea apparently as memory races happen. We should make this more concurrent friendly or use logger per goroutine.

WARNING: DATA RACE
Write at 0x00c000254730 by goroutine 12:
github.com/infrawatch/apputils/logging.(*Logger).Metadata()
/home/para/Projects/go/pkg/mod/github.com/infrawatch/[email protected]/logging/logger.go:80 +0xe4
github.com/infrawatch/sg-core/plugins/transport/socket.(*logWrapper).Infof()
/root/sg-core/plugins/transport/socket/main.go:48 +0x31
github.com/infrawatch/sg-core/plugins/transport/socket.(*Socket).Run()
/root/sg-core/plugins/transport/socket/main.go:87 +0x2b9
github.com/infrawatch/sg-core/cmd/manager.RunTransports.func2()
/root/sg-core/cmd/manager/manager.go:177 +0x153

Previous write at 0x00c000254730 by goroutine 13:
github.com/infrawatch/apputils/logging.(*Logger).writeRecord()
/home/para/Projects/go/pkg/mod/github.com/infrawatch/[email protected]/logging/logger.go:182 +0x201
github.com/infrawatch/apputils/logging.(*Logger).Info()
/home/para/Projects/go/pkg/mod/github.com/infrawatch/[email protected]/logging/logger.go:198 +0x1020
github.com/infrawatch/sg-core/plugins/application/elasticsearch.(*Elasticsearch).Run()
/root/sg-core/plugins/application/elasticsearch/main.go:115 +0x20f
github.com/infrawatch/sg-core/cmd/manager.RunApplications.func1()
/root/sg-core/cmd/manager/manager.go:196 +0xa2

Goroutine 12 (running) created at:
github.com/infrawatch/sg-core/cmd/manager.RunTransports()
/root/sg-core/cmd/manager/manager.go:175 +0x20c
main.main()
/root/sg-core/cmd/main.go:118 +0xe40

Goroutine 13 (running) created at:
github.com/infrawatch/sg-core/cmd/manager.RunApplications()
/root/sg-core/cmd/manager/manager.go:194 +0x14e
main.main()
/root/sg-core/cmd/main.go:119 +0xe78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant