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

fix: [pkg/proxy/listener] [pkg/timeseries/dataset] fix data races #743

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

crandles
Copy link
Contributor

@crandles crandles commented Mar 18, 2025

  • Adds race detection test to CI workflow (but does not fail the CI job)

  • Fixes a race condition provoked by test code in the pkg/proxy/listener package accessing the listener's inner map
Race Condition
WARNING: DATA RACE
Read at 0x00c000456660 by goroutine 50:
  runtime.mapdelete_faststr()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/internal/runtime/maps/runtime_faststr_swiss.go:396 +0x8c
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:69 +0x308
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c000456660 by goroutine 51:
  runtime.mapaccess2()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/internal/runtime/maps/runtime_swiss.go:117 +0x2dc
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:197 +0x824
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00046e0e8 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:69 +0x310
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00046e0e8 by goroutine 51:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:197 +0x830
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00042efc0 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:70 +0x324
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00042efc0 by goroutine 51:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:173 +0x188
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c0004567e0 by goroutine 50:
  golang.org/x/net/netutil.(*limitListener).Close()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:72 +0x2c
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:70 +0x338
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c0004567e0 by goroutine 51:
  golang.org/x/net/netutil.LimitListener()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:17 +0x1e4
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.NewListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:140 +0x1a0
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:184 +0x4a8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00042aa38 by goroutine 50:
  crypto/tls.(*listener).Close()
      <autogenerated>:1 +0x34
  golang.org/x/net/netutil.(*limitListener).Close()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:72 +0x40
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:70 +0x338
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00042aa38 by goroutine 51:
  crypto/tls.NewListener()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/crypto/tls/tls.go:80 +0x12c
  crypto/tls.Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/crypto/tls/tls.go:99 +0x1a4
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.NewListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:130 +0xd8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:184 +0x4a8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00042f000 by goroutine 50:
  net.(*TCPListener).ok()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:156 +0x2c
  net.(*TCPListener).Close()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock.go:390 +0x38
  crypto/tls.(*listener).Close()
      <autogenerated>:1 +0x48
  golang.org/x/net/netutil.(*limitListener).Close()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:72 +0x40
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:70 +0x338
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00042f000 by goroutine 51:
  net.(*sysListener).listenTCPProto()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:193 +0xec
  net.(*sysListener).listenTCP()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:179 +0x3c0
  net.(*ListenConfig).Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/dial.go:821 +0x3a8
  net.Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/dial.go:898 +0x68
  crypto/tls.Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/crypto/tls/tls.go:95 +0x10c
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.NewListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:130 +0xd8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:184 +0x4a8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x19c

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
time=2025-03-18T12:57:11.903374Z app=trickster level=error event="https listener stopping" detail=accept tcp [::]:62014: use of closed network connection listenerName=httpListener
==================
WARNING: DATA RACE
Read at 0x00c0006827d0 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:72 +0x34c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c0006827d0 by goroutine 51:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func2()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:63 +0x1ac

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 51 (finished) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:57 +0x2d4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
time=2025-03-18T12:57:12.004187Z app=trickster level=info event="http listener starting" address= listenerName=httpListener2 port=0
==================
WARNING: DATA RACE
Read at 0x00c000456660 by goroutine 50:
  runtime.mapdelete_faststr()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/internal/runtime/maps/runtime_faststr_swiss.go:396 +0x8c
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:83 +0x4b0
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c000456660 by goroutine 54:
  runtime.mapaccess2()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/internal/runtime/maps/runtime_swiss.go:117 +0x2dc
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:197 +0x824
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListenerRouter()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:254 +0x110
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xa4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00046e100 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:83 +0x4b8
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00046e100 by goroutine 54:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:197 +0x830
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListenerRouter()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:254 +0x110
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xa4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00042f080 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:84 +0x4cc
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00042f080 by goroutine 54:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:173 +0x188
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListenerRouter()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:254 +0x110
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xa4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c000456a50 by goroutine 50:
  golang.org/x/net/netutil.(*limitListener).Close()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:72 +0x2c
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:84 +0x4e0
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c000456a50 by goroutine 54:
  golang.org/x/net/netutil.LimitListener()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:17 +0x1e4
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.NewListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:140 +0x1a0
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:184 +0x4a8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListenerRouter()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:254 +0x110
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xa4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c00042f0c0 by goroutine 50:
  net.(*TCPListener).ok()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:156 +0x2c
  net.(*TCPListener).Close()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock.go:390 +0x38
  golang.org/x/net/netutil.(*limitListener).Close()
      /Users/c/code/oss/trickster/vendor/golang.org/x/net/netutil/listen.go:72 +0x40
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:84 +0x4e0
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00042f0c0 by goroutine 54:
  net.(*sysListener).listenTCPProto()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:193 +0xec
  net.(*sysListener).listenTCP()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/tcpsock_posix.go:179 +0x3c0
  net.(*ListenConfig).Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/dial.go:821 +0x3a8
  net.Listen()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/net/dial.go:898 +0x68
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.NewListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:132 +0x178
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListener()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:184 +0x4a8
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.(*ListenerGroup).StartListenerRouter()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener.go:254 +0x110
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xa4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
time=2025-03-18T12:57:12.306307Z app=trickster level=error event="http listener stopping" detail=accept tcp [::]:62015: use of closed network connection listenerName=httpListener2
==================
WARNING: DATA RACE
Read at 0x00c0006827d0 by goroutine 50:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:86 +0x4f4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c0006827d0 by goroutine 54:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners.func3()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:78 +0xb4

Goroutine 50 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:67 +0x110

Goroutine 54 (finished) created at:
  github.com/trickstercache/trickster/v2/pkg/proxy/listener.TestListeners()
      /Users/c/code/oss/trickster/pkg/proxy/listener/listener_test.go:77 +0x47c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

  • Fix data race in pkg/timeseries/dataset
    • aggregate timeseries results via channel instead of appending same slice via multiple goroutines
Race Condition
WARNING: DATA RACE
Read at 0x00c00009a5d0 by goroutine 92:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:450 +0x8cc
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).CropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:366 +0x150
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.TestCropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset_test.go:336 +0x218
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Previous write at 0x00c00009a5d0 by goroutine 99:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.func1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:446 +0x504
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.gowrap1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:447 +0x44

Goroutine 92 (running) created at:
  testing.(*T).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x684
  testing.runTests.func1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2279 +0x7c
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.runTests()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2277 +0x77c
  testing.(*M).Run()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:2142 +0xb68
  main.main()
      _testmain.go:243 +0x110

Goroutine 99 (finished) created at:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:428 +0xb48
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).CropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:366 +0x150
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.TestCropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset_test.go:336 +0x218
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c000166480 by goroutine 104:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.func1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:446 +0x468
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.gowrap1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:447 +0x44

Previous write at 0x00c000166480 by goroutine 105:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.func1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:446 +0x504
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper.gowrap1()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:447 +0x44

Goroutine 104 (running) created at:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:428 +0xb48
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).CropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:366 +0x150
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.TestCropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset_test.go:336 +0x218
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

Goroutine 105 (finished) created at:
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).DefaultRangeCropper()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:428 +0xb48
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.(*DataSet).CropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset.go:366 +0x150
  github.com/trickstercache/trickster/v2/pkg/timeseries/dataset.TestCropToRange()
      /Users/c/code/oss/trickster/pkg/timeseries/dataset/dataset_test.go:336 +0x218
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1792 +0x180
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.24.1/libexec/src/testing/testing.go:1851 +0x40

@coveralls
Copy link

coveralls commented Mar 18, 2025

Pull Request Test Coverage Report for Build 13980828256

Details

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 86.352%

Totals Coverage Status
Change from base Build 13951105215: 0.003%
Covered Lines: 16489
Relevant Lines: 19095

💛 - Coveralls

@crandles crandles force-pushed the data-race/proxy-listener branch 3 times, most recently from 65bdafe to f35389e Compare March 18, 2025 13:35
Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles force-pushed the data-race/proxy-listener branch from bfcd393 to ca6fd7a Compare March 18, 2025 14:19
@crandles crandles marked this pull request as ready for review March 18, 2025 14:51
@crandles crandles requested a review from jranson March 18, 2025 14:51
@crandles crandles changed the title fix: [pkg/proxy/listener] fix data race in proxy listener tests fix: [pkg/proxy/listener] [pkg/timeseries/dataset] fix data races Mar 18, 2025
@crandles
Copy link
Contributor Author

crandles commented Mar 18, 2025

The race in pkg/timeseries/dataset wasn't so bad on second look.

We're now down to only the pkg/proxy/engines package containing any races.

…gation

Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles force-pushed the data-race/proxy-listener branch from f5a65bf to db488c6 Compare March 19, 2025 17:18
for i := 0; i < valuect; i++ {
vals[i] = int32(rand.Int() % 1000)
}
return Point{
Epoch: e,
Values: []interface{}{},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the generated values weren't being used previously, this seemed like a mistake

…ression test

Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles force-pushed the data-race/proxy-listener branch from bdd632f to 88e6aed Compare March 20, 2025 22:47
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.

3 participants