Skip to content

Memory write races when using logger metadata #65

@paramite

Description

@paramite

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/apputils@v0.0.0-20210325130739-482adc424cd9/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/apputils@v0.0.0-20210325130739-482adc424cd9/logging/logger.go:182 +0x201
github.com/infrawatch/apputils/logging.(*Logger).Info()
/home/para/Projects/go/pkg/mod/github.com/infrawatch/apputils@v0.0.0-20210325130739-482adc424cd9/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions