Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Fix stream race tests #1208

Closed
wants to merge 17 commits into from
Closed

Fix stream race tests #1208

wants to merge 17 commits into from

Conversation

janos
Copy link
Member

@janos janos commented Feb 8, 2019

This PR should solve races and deadlock in the stream package. More details on specific problems in #1198. Every commit in this PR is addressing a different issue, but only the whole PR produces a successful stream test runs with race detectors.

Tests TestSyncingViaGlobalSync and TestSyncerSimulation use a a lot of memory when they are run with race detector, but the largest memory consumer is the leveldb, so this tests have different configuration when running in race mode.

@janos janos self-assigned this Feb 8, 2019
swarm/storage/ldbstore.go Outdated Show resolved Hide resolved
@@ -1049,7 +1049,9 @@ func (s *LDBStore) Close() {
s.lock.Unlock()
// force writing out current batch
s.writeCurrentBatch()
s.lock.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

why need?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is strange, but this is the data race: #1198 (comment).

swarm/network/stream/delivery_test.go Outdated Show resolved Hide resolved
@@ -92,6 +93,15 @@ func TestSyncingViaGlobalSync(t *testing.T) {
if *longrunning {
chnkCnt = []int{1, 8, 32, 256, 1024}
nodeCnt = []int{16, 32, 64, 128, 256}
} else if raceTest {
Copy link
Member

Choose a reason for hiding this comment

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

is this still needed on top of using db vs in memory store?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is.

testSyncBetweenNodes(t, 16, dataChunkCount, true, 1)
// This test uses much more memory when running with
// race detector. Allow it to finish successfully by
// reducing it s scope, and still check for data races
Copy link
Member

Choose a reason for hiding this comment

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

its

swarm/storage/ldbstore.go Outdated Show resolved Hide resolved
@frncmx frncmx self-requested a review February 12, 2019 10:51
Copy link
Contributor

@frncmx frncmx left a comment

Choose a reason for hiding this comment

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

LGTM

Respect for all the work went into this PR! You increase the code/test stability by magnitude.

I like the way you figured how to differentiate between -race and no race mode.
If I go nitpicking as you kinda lie down a standard there - we were able to avoid this differentiation before - I have a minor comment regarding filenames.

By looking at /usr/lib/go/src/internal/race/norace.go and /usr/lib/go/src/internal/race/race.go I would pick the following names for us:

  • race_test.go
  • norace_test.go
  • I would also prefer const raceEnabled but that I can easily let go.

@janos
Copy link
Member Author

janos commented Feb 12, 2019

Thank you @frncmx for a detailed review. I like your suggestions about naming and using constants. I had a trouble with finding the right names, but I did not look into stdlib.

Copy link
Contributor

@frncmx frncmx left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@frncmx frncmx left a comment

Choose a reason for hiding this comment

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

👍

@zelig
Copy link
Member

zelig commented Feb 13, 2019

drop closing of batchesC then can submit upstream

@janos
Copy link
Member Author

janos commented Feb 13, 2019

@zelig thanks, batchesC is not closed.

@janos
Copy link
Member Author

janos commented Feb 13, 2019

Submitted upstream ethereum/go-ethereum#19051.

@janos janos closed this Feb 13, 2019
@frncmx frncmx deleted the fix-stream-race-tests branch February 13, 2019 12:23
@frncmx frncmx mentioned this pull request Feb 15, 2019
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants