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
blockcache: fix datarace in blockcache_test #7029
blockcache: fix datarace in blockcache_test #7029
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MStreet3! Thanks for the PR.
I think the only changes required to solve the linked issue are:
- the
m.RLock()
andm.RUnlock()
in theGetBlock
method ofmockChainBackend
need to converted tom.Lock()
andm.Unlock()
- create the
chainCallCount
getter
a5cfa02
to
6ec1db1
Compare
4b076c3
to
9e22ba6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
I think all of these changes can be squashed into one commit.
Also please add an item to the release notes for this PR
43ed06f
to
0174c14
Compare
mockChainBackend simulates a chain backend and tracks the number of calls via a private property called chainCallCount. This commit uses a write mutex instead of read mutex in the call to GetBlock, adds a getter method to access chainCallCount with a read mutex and uses a write mutex in resetChainCallCount.
5631b54
to
a51e1ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix!
This PR fixes an issue with a data race in the
blockcache
tests.Change Description
GetBlock
instead of a read mutex.resetChainCallCount
instead of a read mutex.chainCallCount
property with a read mutex.Steps to Test
The test failure is a flake (i.e., non-deterministic), but these tests pass with the
-race
flag.fixes #6915