Description
Hi,
I'm currently building a derived library with reconnect handling and my tests fail due to the already closed issue:
In that issue tests were fixed with t.Cleanup
but the actual data race was, as far as I can see, never tackled (?)
Where the assignment to allocator does not seem to be threadsafe (goroutinesafe) resulting in data race detections.
Code lines:
https://github.com/rabbitmq/amqp091-go/blob/main/connection.go#L555
https://github.com/rabbitmq/amqp091-go/blob/main/connection.go#L977
entrypoint for asynchronous memory access (both routines access c.allocator
:
https://github.com/rabbitmq/amqp091-go/blob/main/connection.go#L268-L269
Do I do anything incorrectly?
(test case, which is highly dependent on the go runtime scheduler thus not always triggering the data race: https://github.com/jxsl13/amqpx/blob/batch-handler/pool/connection_test.go#L82)
Any feedback is appreciated.
Thanks for your time.
==================
WARNING: DATA RACE
Write at 0x00c0003e7450 by goroutine 56:
github.com/rabbitmq/amqp091-go.(*Connection).openComplete()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:977 +0x150
github.com/rabbitmq/amqp091-go.(*Connection).openVhost()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:962 +0x1c9
github.com/rabbitmq/amqp091-go.(*Connection).openTune()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:948 +0xc66
github.com/rabbitmq/amqp091-go.(*Connection).openStart()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:885 +0x66f
github.com/rabbitmq/amqp091-go.(*Connection).open()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:857 +0xc4
github.com/rabbitmq/amqp091-go.Open()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:269 +0x664
github.com/rabbitmq/amqp091-go.DialConfig()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:250 +0x904
github.com/jxsl13/amqpx/pool.(*Connection).connect()
/home/jxsl13/Development/amqpx/pool/connection.go:188 +0x33a
github.com/jxsl13/amqpx/pool.(*Connection).Connect()
/home/jxsl13/Development/amqpx/pool/connection.go:176 +0x90
github.com/jxsl13/amqpx/pool.NewConnection()
/home/jxsl13/Development/amqpx/pool/connection.go:98 +0x999
github.com/jxsl13/amqpx/pool_test.TestNewConnectionDisconnect.func1()
/home/jxsl13/Development/amqpx/pool/connection_test.go:97 +0x26b
github.com/jxsl13/amqpx/pool_test.TestNewConnectionDisconnect.func2()
/home/jxsl13/Development/amqpx/pool/connection_test.go:115 +0x47
Previous write at 0x00c0003e7450 by goroutine 335:
github.com/rabbitmq/amqp091-go.(*Connection).shutdown.func1()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:555 +0x4f9
sync.(*Once).doSlow()
/home/jxsl13/sdk/go1.19/src/sync/once.go:74 +0x101
sync.(*Once).Do()
/home/jxsl13/sdk/go1.19/src/sync/once.go:65 +0x46
github.com/rabbitmq/amqp091-go.(*Connection).shutdown()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:522 +0x84
github.com/rabbitmq/amqp091-go.(*Connection).reader()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:662 +0x444
github.com/rabbitmq/amqp091-go.Open.func1()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:268 +0x58
Goroutine 56 (running) created at:
github.com/jxsl13/amqpx/pool_test.TestNewConnectionDisconnect()
/home/jxsl13/Development/amqpx/pool/connection_test.go:94 +0xee
testing.tRunner()
/home/jxsl13/sdk/go1.19/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/home/jxsl13/sdk/go1.19/src/testing/testing.go:1493 +0x47
Goroutine 335 (finished) created at:
github.com/rabbitmq/amqp091-go.Open()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:268 +0x629
github.com/rabbitmq/amqp091-go.DialConfig()
/home/jxsl13/go/pkg/mod/github.com/rabbitmq/amqp091-go@v1.6.1/connection.go:250 +0x904
github.com/jxsl13/amqpx/pool.(*Connection).connect()
/home/jxsl13/Development/amqpx/pool/connection.go:188 +0x33a
github.com/jxsl13/amqpx/pool.(*Connection).Connect()
/home/jxsl13/Development/amqpx/pool/connection.go:176 +0x90
github.com/jxsl13/amqpx/pool.NewConnection()
/home/jxsl13/Development/amqpx/pool/connection.go:98 +0x999
github.com/jxsl13/amqpx/pool_test.TestNewConnectionDisconnect.func1()
/home/jxsl13/Development/amqpx/pool/connection_test.go:97 +0x26b
github.com/jxsl13/amqpx/pool_test.TestNewConnectionDisconnect.func2()
/home/jxsl13/Development/amqpx/pool/connection_test.go:115 +0x47