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

agentlog: fix race condition in tests #4471

Merged

Conversation

christoph-zededa
Copy link
Contributor

@christoph-zededa christoph-zededa commented Dec 10, 2024

Output of the race condition detector was:

=== FAIL: agentlog TestPsiEveIntegratedStartTwice (0.17s) ==================
WARNING: DATA RACE
Write at 0x0000029a6120 by goroutine 80:
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.emulateMemoryPressureStats()
      /pillar/agentlog/agentlog_test.go:301 +0xd1
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.preparePSIEnvironment()
      /pillar/agentlog/agentlog_test.go:455 +0x85
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.TestPsiEveIntegratedStartTwice()
      /pillar/agentlog/agentlog_test.go:616 +0x44
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /usr/lib/go/src/testing/testing.go:1629 +0x47

Previous read at 0x0000029a6120 by goroutine 78:
  github.com/lf-edge/eve/pkg/pillar/agentlog.collectMemoryPSI()
      /pillar/agentlog/memprofile.go:151 +0x116
  github.com/lf-edge/eve/pkg/pillar/agentlog.MemoryPSICollector()
      /pillar/agentlog/memprofile.go:248 +0x810
  github.com/lf-edge/eve/pkg/pillar/agentlog.ListenDebug.func6.1()
      /pillar/agentlog/http-debug.go:474 +0x7e

Goroutine 80 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:1629 +0x805
  testing.runTests.func1()
      /usr/lib/go/src/testing/testing.go:2036 +0x8d
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1576 +0x216
  testing.runTests()
      /usr/lib/go/src/testing/testing.go:2034 +0x87c
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:1906 +0xb44
  main.main()
      _testmain.go:102 +0x2fc

Goroutine 78 (running) created at:
  github.com/lf-edge/eve/pkg/pillar/agentlog.ListenDebug.func6()
      /pillar/agentlog/http-debug.go:473 +0x2ce
  net/http.HandlerFunc.ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2122 +0x4d
  net/http.(*ServeMux).ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2500 +0xc5
  net/http.serverHandler.ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2936 +0x682
  net/http.(*conn).serve()
      /usr/lib/go/src/net/http/server.go:1995 +0xbd4
  net/http.(*Server).Serve.func3()
      /usr/lib/go/src/net/http/server.go:3089 +0x58
==================
    testing.go:1446: race detected during execution of test

Output of the race condition detector was:

=== FAIL: agentlog TestPsiEveIntegratedStartTwice (0.17s)
==================
WARNING: DATA RACE
Write at 0x0000029a6120 by goroutine 80:
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.emulateMemoryPressureStats()
      /pillar/agentlog/agentlog_test.go:301 +0xd1
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.preparePSIEnvironment()
      /pillar/agentlog/agentlog_test.go:455 +0x85
  github.com/lf-edge/eve/pkg/pillar/agentlog_test.TestPsiEveIntegratedStartTwice()
      /pillar/agentlog/agentlog_test.go:616 +0x44
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /usr/lib/go/src/testing/testing.go:1629 +0x47

Previous read at 0x0000029a6120 by goroutine 78:
  github.com/lf-edge/eve/pkg/pillar/agentlog.collectMemoryPSI()
      /pillar/agentlog/memprofile.go:151 +0x116
  github.com/lf-edge/eve/pkg/pillar/agentlog.MemoryPSICollector()
      /pillar/agentlog/memprofile.go:248 +0x810
  github.com/lf-edge/eve/pkg/pillar/agentlog.ListenDebug.func6.1()
      /pillar/agentlog/http-debug.go:474 +0x7e

Goroutine 80 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:1629 +0x805
  testing.runTests.func1()
      /usr/lib/go/src/testing/testing.go:2036 +0x8d
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:1576 +0x216
  testing.runTests()
      /usr/lib/go/src/testing/testing.go:2034 +0x87c
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:1906 +0xb44
  main.main()
      _testmain.go:102 +0x2fc

Goroutine 78 (running) created at:
  github.com/lf-edge/eve/pkg/pillar/agentlog.ListenDebug.func6()
      /pillar/agentlog/http-debug.go:473 +0x2ce
  net/http.HandlerFunc.ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2122 +0x4d
  net/http.(*ServeMux).ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2500 +0xc5
  net/http.serverHandler.ServeHTTP()
      /usr/lib/go/src/net/http/server.go:2936 +0x682
  net/http.(*conn).serve()
      /usr/lib/go/src/net/http/server.go:1995 +0xbd4
  net/http.(*Server).Serve.func3()
      /usr/lib/go/src/net/http/server.go:3089 +0x58
==================
    testing.go:1446: race detected during execution of test

Signed-off-by: Christoph Ostarek <[email protected]>
Copy link
Member

@OhmSpectator OhmSpectator left a comment

Choose a reason for hiding this comment

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

I though we already run go test with --race flag... How did you discover this issue and why didn't we see it before?...

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

@rene
Copy link
Contributor

rene commented Dec 12, 2024

Re-running failed Eden tests...

@eriknordmark eriknordmark merged commit 59a07dd into lf-edge:master Dec 12, 2024
45 checks passed
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.

4 participants