connection: fix future release race on reconnect - #601
Merged
Merged
Conversation
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
olegrok
approved these changes
Sep 10, 2026
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
force-pushed
the
oleg-jukovec/gh-600-fix-data-race
branch
from
September 10, 2026 08:58
2864846 to
19b5655
Compare
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
force-pushed
the
oleg-jukovec/gh-600-fix-data-race
branch
from
September 10, 2026 09:03
19b5655 to
f82bc8b
Compare
sssciel
requested changes
Sep 10, 2026
sssciel
approved these changes
Sep 10, 2026
bigbes
approved these changes
Sep 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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