You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fluent: make connection closed variable thread-safe
Changed the "closed" variable to be an atomic int. There is a race condition b/w
appendBuffer and Close() method wrt how this variable is accessed. This could be
an atomic.Bool, but the CI/CD config uses golang version 1.17. Since atomic.Bool
is supported 1.19 onwards, using that would fail tests and build.
Data race trace without this fix (using `go test -race`):
==================
WARNING: DATA RACE
Write at 0x00c0003324e0 by goroutine 95:
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).close()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:426 +0x13c
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).Close()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:393 +0x108
github.com/fluent/fluent-logger-golang/fluent.TestCloseWhileWaitingForAckResponse.func1()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent_test.go:737 +0x2c
github.com/fluent/fluent-logger-golang/fluent.timeout.func1()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent_test.go:557 +0x38
Previous read at 0x00c0003324e0 by goroutine 94:
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).write()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:619 +0x1ac
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).writeWithRetry()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:553 +0x78
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).run()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:527 +0x1d0
github.com/fluent/fluent-logger-golang/fluent.newWithDialer.gowrap1()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:184 +0x4c
Goroutine 95 (running) created at:
github.com/fluent/fluent-logger-golang/fluent.timeout()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent_test.go:556 +0xe8
github.com/fluent/fluent-logger-golang/fluent.TestCloseWhileWaitingForAckResponse()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent_test.go:736 +0x444
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.2/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.2/libexec/src/testing/testing.go:1851 +0x40
Goroutine 94 (running) created at:
github.com/fluent/fluent-logger-golang/fluent.newWithDialer()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent.go:184 +0x368
github.com/fluent/fluent-logger-golang/fluent.TestCloseWhileWaitingForAckResponse()
/Users/aithal/workspace/src/github.com/aaithal/fluent-logger-golang/fluent/fluent_test.go:722 +0xd8
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.2/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.2/libexec/src/testing/testing.go:1851 +0x40
==================
[2025-05-06T08:42:08-07:00] Discarding queued events...
testing.go:1490: race detected during execution of test
Signed-off-by: Anirudh Aithal <aithal@amazon.com>
0 commit comments