-
Notifications
You must be signed in to change notification settings - Fork 20.9k
eth/downloader: fix race condition in tests #22140
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
Conversation
Hm. I don't see how this fixes any race -- do you have any more context, e.g. from the race detector? |
Sorry @holiman that I haven't added the initial error. The actual point where the race is being occurred is https://github.com/ethereum/go-ethereum/blob/master/eth/downloader/downloader.go#L387-L389 Traceback from master branch follows:
|
The CI's failing tests doesn't seem to be related to this change. |
Based on the output from that race detector, it seems to me that this would be a more accurate fix: diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go
index 6578275d0c..5de1ef3f8e 100644
--- a/eth/downloader/downloader_test.go
+++ b/eth/downloader/downloader_test.go
@@ -584,14 +584,15 @@ func testThrottling(t *testing.T, protocol uint, mode SyncMode) {
time.Sleep(25 * time.Millisecond)
tester.lock.Lock()
+ tester.downloader.queue.lock.Lock()
+ tester.downloader.queue.resultCache.lock.Lock()
{
- tester.downloader.queue.resultCache.lock.Lock()
cached = tester.downloader.queue.resultCache.countCompleted()
- tester.downloader.queue.resultCache.lock.Unlock()
frozen = int(atomic.LoadUint32(&blocked))
retrieved = len(tester.ownBlocks)
-
}
+ tester.downloader.queue.resultCache.lock.Unlock()
+ tester.downloader.queue.lock.Unlock()
tester.lock.Unlock()
if cached == blockCacheMaxItems || |
Thanks @holiman. I am wondering if you agree that it makes sense to also leave my initial commit, as it mimics how the |
I don't know, I don't really see any reason for it, but I can be convinced... Does not allocating the sync bloom make the tests run any faster? I would probably prefer to leave the bulk of the code untouched if there's no really solid reason to change it |
No, I don't have a solid reason for it. I will revert the commit and feel free to squash merge it :) |
This reverts commit 108033e.
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!
Running this cmd:
was giving race condition issues.
This PR fixes the minor race condition in the tests.