Skip to content

Race in BrokerDetails.clientDisconnect between Disconnect and connectionWatcher #101

Description

@miotte

BrokerDetails.clientDisconnect (bool) is written by DisconnectdisconnectClientByIdentifier (amqp091.go:1337) and concurrently read by the background connectionWatcher goroutine spawned in Connect (amqp091.go:511). The reads sit in the outer watcher loop (amqp091.go:1797), the inner reconnect loop (amqp091.go:1817), and the connect() early-out (amqp091.go:1863). None of these accesses are synchronized — the sync.Mutex already on BrokerDetails guards bd.state but not this flag.

The race detector reliably flags it during Test_StreamRetry, and as a side-effect it also surfaces under several other tests that exercise the Connect/Disconnect path (Test_Disconnect, Test_SubscribeStream*).

The streamConnectionShim in streamshim.go:40 already uses atomic.Bool for the analogous flag, so the fix is to mirror that pattern on BrokerDetails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggoPull requests that update go code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions