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

network: fix data race TestGetData #3315

Closed
wants to merge 3 commits into from
Closed

Conversation

AliceInHunterland
Copy link
Contributor

Close #2974

To prevent "closed twice" used started atomic.Bool to ensure that the
shutdown
procedure is executed only once. `--- FAIL: TestServerRegisterPeer (0
.06s)
 panic: closed twice
 goroutine 60 [running]:
 testing.tRunner.func1.2({0x104c40b20, 0x104d0ec90})
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1545 +0x1c8
 testing.tRunner.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1548 +0x360
 panic({0x104c40b20?, 0x104d0ec90?})
 	/opt/homebrew/opt/go/libexec/src/runtime/panic.go:914 +0x218
 github.com/nspcc-dev/neo-go/pkg/network.(*fakeTransp).Close
 (0x14000159e08?)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network
 	/discovery_test.go:83 +0x54
 github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown
 (0x14000343400)
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server.go:299
 	 +0x104
 github.com/nspcc-dev/neo-go/pkg/network.startWithCleanup.func1()
 	/Users/ekaterinapavlova/Workplace/neo-go/pkg/network/server_test
 	.go:408 +0x20
 testing.(*common).Cleanup.func1()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1169 +0x110
 testing.(*common).runCleanup(0x1400032c340, 0x14000159d80?)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1347 +0xd8
 testing.tRunner.func2()
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1589 +0x2c
 testing.tRunner(0x1400032c340, 0x104d0c5d0)
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1601 +0x114
 created by testing.(*T).Run in goroutine 1
 	/opt/homebrew/opt/go/libexec/src/testing/testing.go:1648 +0x33c`

Signed-off-by: Ekaterina Pavlova <[email protected]>
To prevent writing to logs after the end of the test execution
concurrent registration and handshakes put to separate goroutines.

Close #2973

Signed-off-by: Ekaterina Pavlova <[email protected]>
Log writing after the end of the test can be the reason of data race.

Close #2974

Signed-off-by: Ekaterina Pavlova <[email protected]>
Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (51ac153) 84.96% compared to head (856562b) 84.94%.

Files Patch % Lines
pkg/network/server.go 42.85% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3315      +/-   ##
==========================================
- Coverage   84.96%   84.94%   -0.02%     
==========================================
  Files         328      328              
  Lines       44747    44754       +7     
==========================================
- Hits        38020    38017       -3     
- Misses       5216     5224       +8     
- Partials     1511     1513       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnnaShaleva
Copy link
Member

Closing this PR as not relevant since the logger problem will be fixed in #3307. Ref. #3307 (comment).

@AliceInHunterland AliceInHunterland deleted the TestGetData branch February 15, 2024 08:26
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.

Race in TestGetData/p2pNotaryRequest
2 participants