Open yondonfu opened 2 years ago
Minimal reproducible example:
cd server
go test -v -run "TestPush_OSPerStream|TestPush_MultipartReturnMultiSession" -race
Output:
WARNING: DATA RACE
Write at 0x0000026a88c8 by goroutine 76:
github.com/livepeer/go-livepeer/server.setupServerWithCancel()
/projects/livepeer/src/go-livepeer/server/mediaserver_test.go:83 +0x14b
github.com/livepeer/go-livepeer/server.TestPush_MultipartReturnMultiSession()
/projects/livepeer/src/go-livepeer/server/push_test.go:1539 +0x104
testing.tRunner()
/home/flame/go/go1.17/src/testing/testing.go:1259 +0x22f
testing.(*T).Run·dwrap·21()
/home/flame/go/go1.17/src/testing/testing.go:1306 +0x47
Previous read at 0x0000026a88c8 by goroutine 40:
github.com/livepeer/go-livepeer/server.(*LivepeerServer).HandlePush.func4()
/projects/livepeer/src/go-livepeer/server/mediaserver.go:954 +0xd0
Goroutine 76 (running) created at:
testing.(*T).Run()
/home/flame/go/go1.17/src/testing/testing.go:1306 +0x726
testing.runTests.func1()
/home/flame/go/go1.17/src/testing/testing.go:1598 +0x99
testing.tRunner()
/home/flame/go/go1.17/src/testing/testing.go:1259 +0x22f
testing.runTests()
/home/flame/go/go1.17/src/testing/testing.go:1596 +0x7ca
testing.(*M).Run()
/home/flame/go/go1.17/src/testing/testing.go:1504 +0x9d1
main.main()
_testmain.go:503 +0x22b
Goroutine 40 (finished) created at:
github.com/livepeer/go-livepeer/server.(*LivepeerServer).HandlePush()
/projects/livepeer/src/go-livepeer/server/mediaserver.go:952 +0x1eb8
github.com/livepeer/go-livepeer/server.requestSetup.func1()
/projects/livepeer/src/go-livepeer/server/push_test.go:38 +0x4e
net/http.HandlerFunc.ServeHTTP()
/home/flame/go/go1.17/src/net/http/server.go:2046 +0x4d
github.com/livepeer/go-livepeer/server.TestPush_OSPerStream()
/projects/livepeer/src/go-livepeer/server/push_test.go:1319 +0xfae
testing.tRunner()
/home/flame/go/go1.17/src/testing/testing.go:1259 +0x22f
testing.(*T).Run·dwrap·21()
/home/flame/go/go1.17/src/testing/testing.go:1306 +0x47
See https://github.com/livepeer/go-livepeer/issues/2145#issuecomment-1002971675
The relevant tests are in https://github.com/livepeer/go-livepeer/blob/970d0aa7892cd9c30aaf069a7ee8e72d8fa64111/server/push_test.go.
We may want to look into refactoring these tests altogether as it sounds like the way synchronization is currently handled is problematic and will lead to data race conditions when running with
go test -race
.