Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: serialize NetworkTransport data race on ServerAddr() #591

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

moogacs
Copy link
Contributor

@moogacs moogacs commented Apr 2, 2024

ServerAddr() is called concurrently through AppendEntries, RequestVote.
for example getConn() is thread safe here by calling connPoolLock, however getProviderAddressOrFallback() is not thread safe.

given that the lib doesn't control which data type is used by the consumer and there is no documentation for how ServerAddr() could be used by RAFT lib, so this PR protecting reading ServerAddr() by adding RWMutex to the NetworkTransport and serialize access to serverAddressLock

@moogacs moogacs requested a review from a team as a code owner April 2, 2024 03:57
@moogacs moogacs requested review from DanStough and removed request for a team April 2, 2024 03:57
Copy link
Member

@jmurret jmurret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @moogacs !

@jmurret jmurret merged commit 341ea38 into hashicorp:main Apr 26, 2024
12 checks passed
@gavraz
Copy link

gavraz commented Aug 13, 2024

Hey,
I came across this PR and noticed and noticed there is no invocation of serverAddressLock.Lock which suggests this has no effect since we only handle reads.

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.

3 participants