Skip to content

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

Merged
jmurret merged 1 commit intohashicorp:mainfrom
moogacs:main
Apr 26, 2024
Merged

fix: serialize NetworkTransport data race on ServerAddr()#591
jmurret merged 1 commit intohashicorp:mainfrom
moogacs:main

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
@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