Skip to content

connection: fix future release race on reconnect - #601

Merged
oleg-jukovec merged 2 commits into
masterfrom
oleg-jukovec/gh-600-fix-data-race
Sep 10, 2026
Merged

oleg-jukovec merged 2 commits into
masterfrom
oleg-jukovec/gh-600-fix-data-race

Conversation

@oleg-jukovec

Copy link
Copy Markdown
Collaborator

Reconnecting while requests were in-flight could leave callers blocked forever or cause panics in the documented Do -> Get -> Release lifecycle. The internal cleanup of pending futures on reconnect wrote a future's list link after setError() had already unblocked the caller, racing with Release() zeroing the same object and returning it to the pool for reuse by a new Do(). The late write could drop the new request from the connection's tracking list, so its response was never matched back.

What has been done? Why? What problem is being solved?

I didn't forget about (remove if it is not applicable):

Related issues:

Closes #600

Reconnecting while requests were in-flight could leave callers
blocked forever or cause panics in the documented Do -> Get ->
Release lifecycle. The internal cleanup of pending futures on
reconnect wrote a future's list link after setError() had already
unblocked the caller, racing with Release() zeroing the same object
and returning it to the pool for reuse by a new Do(). The late write
could drop the new request from the connection's tracking list, so
its response was never matched back.

Closes #600
oleg-jukovec added a commit that referenced this pull request Sep 10, 2026
Connection.Addr() read the addr field without holding the
mutex, while dial() wrote it during background reconnects.
When user code called Addr() concurrently with a reconnect
(e.g. after a server restart or network blip), the Go race
detector reported a data race and the returned address could
be stale or partially updated.

Closes #601
oleg-jukovec added a commit that referenced this pull request Sep 10, 2026
Connection.Addr() read the addr field without holding the
mutex, while dial() wrote it during background reconnects.
When user code called Addr() concurrently with a reconnect
(e.g. after a server restart or network blip), the Go race
detector reported a data race and the returned address could
be stale or partially updated.

Closes #601
@oleg-jukovec
oleg-jukovec force-pushed the oleg-jukovec/gh-600-fix-data-race branch from 2864846 to 19b5655 Compare September 10, 2026 08:58
Connection.Addr() read the addr field without holding the
mutex, while dial() wrote it during background reconnects.
When user code called Addr() concurrently with a reconnect
(e.g. after a server restart or network blip), the Go race
detector reported a data race and the returned address could
be stale or partially updated.

Follows #600
@oleg-jukovec
oleg-jukovec force-pushed the oleg-jukovec/gh-600-fix-data-race branch from 19b5655 to f82bc8b Compare September 10, 2026 09:03
Comment thread connection.go
@oleg-jukovec
oleg-jukovec merged commit 802388c into master Sep 10, 2026
27 checks passed
@oleg-jukovec
oleg-jukovec deleted the oleg-jukovec/gh-600-fix-data-race branch September 10, 2026 11:53
@oleg-jukovec oleg-jukovec mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data race between Future.Release() and futureList.clear() on reconnect

4 participants