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

Enable the race detector on Sytest tests #745

Closed
wants to merge 4 commits into from

Conversation

anoadragon453
Copy link
Member

Enable the go race detector.

Upon doing so, I found we indeed have race conditions!

Race conditions
➜  dendrite git:(anoa/race_detector) ✗ go test -race ./...
?       github.com/matrix-org/dendrite/appservice       [no test files]
?       github.com/matrix-org/dendrite/appservice/api   [no test files]
?       github.com/matrix-org/dendrite/appservice/consumers     [no test files]
?       github.com/matrix-org/dendrite/appservice/query [no test files]
?       github.com/matrix-org/dendrite/appservice/routing       [no test files]
?       github.com/matrix-org/dendrite/appservice/storage       [no test files]
?       github.com/matrix-org/dendrite/appservice/types [no test files]
?       github.com/matrix-org/dendrite/appservice/workers       [no test files]
?       github.com/matrix-org/dendrite/clientapi        [no test files]
?       github.com/matrix-org/dendrite/clientapi/auth   [no test files]
?       github.com/matrix-org/dendrite/clientapi/auth/authtypes [no test files]
?       github.com/matrix-org/dendrite/clientapi/auth/storage/accounts  [no test files]
?       github.com/matrix-org/dendrite/clientapi/auth/storage/devices   [no test files]
?       github.com/matrix-org/dendrite/clientapi/consumers      [no test files]
?       github.com/matrix-org/dendrite/clientapi/httputil       [no test files]
ok      github.com/matrix-org/dendrite/clientapi/jsonerror      1.020s
?       github.com/matrix-org/dendrite/clientapi/producers      [no test files]
ok      github.com/matrix-org/dendrite/clientapi/routing        1.019s
?       github.com/matrix-org/dendrite/clientapi/threepid       [no test files]
ok      github.com/matrix-org/dendrite/clientapi/userutil       1.017s
?       github.com/matrix-org/dendrite/cmd/client-api-proxy     [no test files]
?       github.com/matrix-org/dendrite/cmd/create-account       [no test files]
?       github.com/matrix-org/dendrite/cmd/create-room-events   [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-appservice-server   [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-client-api-server   [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-federation-api-server       [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-federation-sender-server    [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-media-api-server    [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-monolith-server     [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-public-rooms-api-server     [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-room-server [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-sync-api-server     [no test files]
?       github.com/matrix-org/dendrite/cmd/dendrite-typing-server       [no test files]
?       github.com/matrix-org/dendrite/cmd/federation-api-proxy [no test files]
?       github.com/matrix-org/dendrite/cmd/generate-keys        [no test files]
?       github.com/matrix-org/dendrite/cmd/kafka-producer       [no test files]
?       github.com/matrix-org/dendrite/cmd/mediaapi-integration-tests   [no test files]
?       github.com/matrix-org/dendrite/cmd/roomserver-integration-tests [no test files]
?       github.com/matrix-org/dendrite/cmd/syncserver-integration-tests [no test files]
?       github.com/matrix-org/dendrite/common   [no test files]
?       github.com/matrix-org/dendrite/common/basecomponent     [no test files]
ok      github.com/matrix-org/dendrite/common/config    1.012s
?       github.com/matrix-org/dendrite/common/http      [no test files]
?       github.com/matrix-org/dendrite/common/keydb     [no test files]
?       github.com/matrix-org/dendrite/common/test      [no test files]
ok      github.com/matrix-org/dendrite/common/transactions      1.007s
?       github.com/matrix-org/dendrite/federationapi    [no test files]
?       github.com/matrix-org/dendrite/federationapi/routing    [no test files]
?       github.com/matrix-org/dendrite/federationapi/types      [no test files]
?       github.com/matrix-org/dendrite/federationsender [no test files]
ok      github.com/matrix-org/dendrite/federationsender/consumers       1.008s
?       github.com/matrix-org/dendrite/federationsender/queue   [no test files]
?       github.com/matrix-org/dendrite/federationsender/storage [no test files]
?       github.com/matrix-org/dendrite/federationsender/types   [no test files]
?       github.com/matrix-org/dendrite/mediaapi [no test files]
?       github.com/matrix-org/dendrite/mediaapi/fileutils       [no test files]
?       github.com/matrix-org/dendrite/mediaapi/routing [no test files]
?       github.com/matrix-org/dendrite/mediaapi/storage [no test files]
?       github.com/matrix-org/dendrite/mediaapi/thumbnailer     [no test files]
?       github.com/matrix-org/dendrite/mediaapi/types   [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi   [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi/consumers [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi/directory [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi/routing   [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi/storage   [no test files]
?       github.com/matrix-org/dendrite/publicroomsapi/types     [no test files]
?       github.com/matrix-org/dendrite/roomserver       [no test files]
ok      github.com/matrix-org/dendrite/roomserver/alias 1.008s
?       github.com/matrix-org/dendrite/roomserver/api   [no test files]
?       github.com/matrix-org/dendrite/roomserver/auth  [no test files]
ok      github.com/matrix-org/dendrite/roomserver/input 1.010s
ok      github.com/matrix-org/dendrite/roomserver/query 1.010s
ok      github.com/matrix-org/dendrite/roomserver/state 1.009s
ok      github.com/matrix-org/dendrite/roomserver/storage       1.010s
?       github.com/matrix-org/dendrite/roomserver/types [no test files]
?       github.com/matrix-org/dendrite/syncapi  [no test files]
?       github.com/matrix-org/dendrite/syncapi/consumers        [no test files]
?       github.com/matrix-org/dendrite/syncapi/routing  [no test files]
?       github.com/matrix-org/dendrite/syncapi/storage  [no test files]
==================
WARNING: DATA RACE
Read at 0x00c000164000 by goroutine 11:
  runtime.mapaccess2_faststr()
      /home/user/.go/src/runtime/map_faststr.go:107 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0x99
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:136 +0x12a

Previous write at 0x00c000164000 by goroutine 10:
  runtime.mapassign_faststr()
      /home/user/.go/src/runtime/map_faststr.go:202 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x2ff
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:146 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 11 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:135 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 10 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Read at 0x00c0000939b8 by goroutine 11:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0xbb
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:136 +0x12a

Previous write at 0x00c0000939b8 by goroutine 10:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x314
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:146 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 11 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:135 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 10 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Write at 0x00c0000c6830 by goroutine 11:
  sync/atomic.CompareAndSwapInt32()
      /home/user/.go/src/runtime/race_amd64.s:293 +0xb
  sync.(*Mutex).Lock()
      /home/user/.go/src/sync/mutex.go:74 +0x4d
  github.com/matrix-org/dendrite/syncapi/sync.(*UserStream).GetListener()
      /home/user/code/dendrite/syncapi/sync/userstream.go:67 +0x55
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0x100
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:136 +0x12a

Previous write at 0x00c0000c6830 by goroutine 10:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/userstream.go:59 +0x1b0
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:146 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 11 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:135 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 10 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
--- FAIL: TestNewEventAndJoinedToRoom (0.00s)
    testing.go:809: race detected during execution of test
==================
WARNING: DATA RACE
Read at 0x00c0001320f0 by goroutine 14:
  runtime.mapaccess2_faststr()
      /home/user/.go/src/runtime/map_faststr.go:107 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0x99
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:164 +0x12a

Previous write at 0x00c0001320f0 by goroutine 13:
  runtime.mapassign_faststr()
      /home/user/.go/src/runtime/map_faststr.go:202 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x2ff
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:174 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 14 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:163 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 13 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Read at 0x00c0001282f8 by goroutine 14:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0xbb
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:164 +0x12a

Previous write at 0x00c0001282f8 by goroutine 13:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x314
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:174 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 14 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:163 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 13 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Write at 0x00c000144060 by goroutine 14:
  sync/atomic.CompareAndSwapInt32()
      /home/user/.go/src/runtime/race_amd64.s:293 +0xb
  sync.(*Mutex).Lock()
      /home/user/.go/src/sync/mutex.go:74 +0x4d
  github.com/matrix-org/dendrite/syncapi/sync.(*UserStream).GetListener()
      /home/user/code/dendrite/syncapi/sync/userstream.go:67 +0x55
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0x100
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:164 +0x12a

Previous write at 0x00c000144060 by goroutine 13:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/userstream.go:59 +0x1b0
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:174 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 14 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewInviteEventForUser()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:163 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 13 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
--- FAIL: TestNewInviteEventForUser (0.00s)
    testing.go:809: race detected during execution of test
==================
WARNING: DATA RACE
Read at 0x00c00019c210 by goroutine 18:
  runtime.mapaccess2_faststr()
      /home/user/.go/src/runtime/map_faststr.go:107 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0x99
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:192 +0x12a

Previous write at 0x00c00019c210 by goroutine 17:
  runtime.mapassign_faststr()
      /home/user/.go/src/runtime/map_faststr.go:202 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x2ff
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:202 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 18 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:191 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 17 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Read at 0x00c0001b22f8 by goroutine 18:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0xbb
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:192 +0x12a

Previous write at 0x00c0001b22f8 by goroutine 17:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x314
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:202 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 18 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:191 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 17 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Write at 0x00c0001aa010 by goroutine 18:
  sync/atomic.CompareAndSwapInt32()
      /home/user/.go/src/runtime/race_amd64.s:293 +0xb
  sync.(*Mutex).Lock()
      /home/user/.go/src/sync/mutex.go:74 +0x4d
  github.com/matrix-org/dendrite/syncapi/sync.(*UserStream).GetListener()
      /home/user/code/dendrite/syncapi/sync/userstream.go:67 +0x55
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0x100
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:192 +0x12a

Previous write at 0x00c0001aa010 by goroutine 17:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/userstream.go:59 +0x1b0
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:202 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 18 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestEDUWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:191 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 17 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
--- FAIL: TestEDUWakeup (0.00s)
    testing.go:809: race detected during execution of test
==================
WARNING: DATA RACE
Read at 0x00c0001d0090 by goroutine 19:
  runtime.mapaccess2_faststr()
      /home/user/.go/src/runtime/map_faststr.go:107 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0x99
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:233 +0x5f1
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Previous write at 0x00c0001d0090 by goroutine 20:
  runtime.mapassign_faststr()
      /home/user/.go/src/runtime/map_faststr.go:202 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x2ff
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:220 +0x15e

Goroutine 19 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222

Goroutine 20 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:229 +0x581
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
==================
==================
WARNING: DATA RACE
Read at 0x00c000093a88 by goroutine 19:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0xbb
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:233 +0x5f1
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Previous write at 0x00c000093a88 by goroutine 20:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x314
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:220 +0x15e

Goroutine 19 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222

Goroutine 20 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:229 +0x581
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
==================
==================
WARNING: DATA RACE
Write at 0x00c0000c68d0 by goroutine 19:
  sync/atomic.CompareAndSwapInt32()
      /home/user/.go/src/runtime/race_amd64.s:293 +0xb
  sync.(*Mutex).Lock()
      /home/user/.go/src/sync/mutex.go:74 +0x4d
  github.com/matrix-org/dendrite/syncapi/sync.(*UserStream).NumWaiting()
      /home/user/code/dendrite/syncapi/sync/userstream.go:102 +0x50
  github.com/matrix-org/dendrite/syncapi/sync.waitForBlocking()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:325 +0x47
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:234 +0x60d
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Previous write at 0x00c0000c68d0 by goroutine 20:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/userstream.go:59 +0x1b0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:220 +0x15e

Goroutine 19 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222

Goroutine 20 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestMultipleRequestWakeup()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:229 +0x581
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
==================
--- FAIL: TestMultipleRequestWakeup (0.00s)
    testing.go:809: race detected during execution of test
==================
WARNING: DATA RACE
Read at 0x00c00019c360 by goroutine 24:
  runtime.mapaccess2_faststr()
      /home/user/.go/src/runtime/map_faststr.go:107 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0x99
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:260 +0x12a

Previous write at 0x00c00019c360 by goroutine 23:
  runtime.mapassign_faststr()
      /home/user/.go/src/runtime/map_faststr.go:202 +0x0
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x2ff
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:269 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 24 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:259 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 23 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Read at 0x00c0001b2498 by goroutine 24:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:189 +0xbb
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0xde
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:260 +0x12a

Previous write at 0x00c0001b2498 by goroutine 23:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/notifier.go:193 +0x314
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:269 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 24 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:259 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 23 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
==================
WARNING: DATA RACE
Write at 0x00c0001aa0b0 by goroutine 24:
  sync/atomic.CompareAndSwapInt32()
      /home/user/.go/src/runtime/race_amd64.s:293 +0xb
  sync.(*Mutex).Lock()
      /home/user/.go/src/sync/mutex.go:74 +0x4d
  github.com/matrix-org/dendrite/syncapi/sync.(*UserStream).GetListener()
      /home/user/code/dendrite/syncapi/sync/userstream.go:67 +0x55
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).GetListener()
      /home/user/code/dendrite/syncapi/sync/notifier.go:140 +0x100
  github.com/matrix-org/dendrite/syncapi/sync.waitForEvents()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:309 +0xc6
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom.func1()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:260 +0x12a

Previous write at 0x00c0001aa0b0 by goroutine 23:
  github.com/matrix-org/dendrite/syncapi/sync.(*Notifier).fetchUserStream()
      /home/user/code/dendrite/syncapi/sync/userstream.go:59 +0x1b0
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:269 +0x4f5
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 24 (running) created at:
  github.com/matrix-org/dendrite/syncapi/sync.TestNewEventAndWasPreviouslyJoinedToRoom()
      /home/user/code/dendrite/syncapi/sync/notifier_test.go:259 +0x4ba
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163

Goroutine 23 (running) created at:
  testing.(*T).Run()
      /home/user/.go/src/testing/testing.go:916 +0x65a
  testing.runTests.func1()
      /home/user/.go/src/testing/testing.go:1157 +0xa8
  testing.tRunner()
      /home/user/.go/src/testing/testing.go:865 +0x163
  testing.runTests()
      /home/user/.go/src/testing/testing.go:1155 +0x523
  testing.(*M).Run()
      /home/user/.go/src/testing/testing.go:1072 +0x2eb
  main.main()
      _testmain.go:52 +0x222
==================
--- FAIL: TestNewEventAndWasPreviouslyJoinedToRoom (0.00s)
    testing.go:809: race detected during execution of test
FAIL
FAIL    github.com/matrix-org/dendrite/syncapi/sync     0.016s
?       github.com/matrix-org/dendrite/syncapi/types    [no test files]
?       github.com/matrix-org/dendrite/typingserver     [no test files]
?       github.com/matrix-org/dendrite/typingserver/api [no test files]
ok      github.com/matrix-org/dendrite/typingserver/cache       1.008s
?       github.com/matrix-org/dendrite/typingserver/input       [no test files]

The test cases have been allowed to fail now, but separate PRs should be made to fix these race conditions, such that we can later drop the soft fail again.

Fixes #491

@anoadragon453 anoadragon453 requested review from Cnly and a team July 17, 2019 14:05
@Cnly
Copy link
Contributor

Cnly commented Jul 18, 2019

It turns out the races are in the tests - #748. Maybe we can merge that first and drop the soft fail? Perhaps also enable the race detector when running SyTest?

@anoadragon453
Copy link
Member Author

I wonder where we're actually going to see race conditions brought out by sytest...

@anoadragon453
Copy link
Member Author

Removed the soft-fail and moving the pipeline bits to a PR on https://github.com/matrix-org/pipelines

@anoadragon453 anoadragon453 changed the title Enable the race detector and soft fail tests Enable the race detector on Sytest tests Jul 25, 2019
@anoadragon453
Copy link
Member Author

Moved unit test race stuff to matrix-org/pipelines#2

I think we may want to wait on this one until we fix the races that Sytest brings up, otherwise we'll suffer from much slower CI.

@anoadragon453
Copy link
Member Author

Race condition found in sytest: #780

@anoadragon453 anoadragon453 self-assigned this Aug 15, 2019
@kegsay
Copy link
Member

kegsay commented Mar 14, 2020

What's the status of this @anoadragon453 ? I'd obviously like to have race detection for sytests - what is the performance hit if we enabled this by default?

@kegsay kegsay self-assigned this Mar 14, 2020
@anoadragon453
Copy link
Member Author

IIRC it did have a noticeable performance hit, but I'd try it again and see if things have improved in the newer go versions.

The race conditions mentioned in this issue were fixed but more may have cropped up with code change.

Feel free to take this and:

  • Check for existing race conditions
  • Benchmark sytest vs. non-race systest

You'll want to fix any existing race conditions before merging the option to CI ofc.

@Cnly
Copy link
Contributor

Cnly commented Apr 17, 2020

On my local machine, running a full SyTest test with race detector on uses ~2x time. Good thing is that I don't see any race conditions in the output.

It seems this line in SyTest needs to be removed in order to see the race condition warnings in the output: https://github.com/matrix-org/sytest/blob/034199da24c60014751503a059fe1ea7ac757381/lib/SyTest/Homeserver/ProcessManager.pm#L112

@kegsay
Copy link
Member

kegsay commented May 21, 2020

I'm going to close this for now because a 2x hit on speed is pretty bad. We already feel the pain having it be 17 minutes long, so bumping it to 34 minutes is unacceptable.

For now, let's manually and periodically run the race detector.

@kegsay kegsay closed this May 21, 2020
@kegsay kegsay deleted the anoa/race_detector branch April 6, 2022 13:31
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.

Add race condition checking to CI
3 participants