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

Race condition in configtls #8395

Closed
djaglowski opened this issue Sep 12, 2023 · 0 comments · Fixed by #8437
Closed

Race condition in configtls #8395

djaglowski opened this issue Sep 12, 2023 · 0 comments · Fixed by #8437
Labels
bug Something isn't working

Comments

@djaglowski
Copy link
Member

Observed in TestErrorRecordedIfFileDeleted here: https://github.com/open-telemetry/opentelemetry-collector/actions/runs/6163502394/job/16727198407?pr=8344#step:6:75

make[2]: Entering directory '/home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls'
go test -race -timeout 120s ./...
==================
WARNING: DATA RACE
Read at 0x00c000012048 by goroutine 16:
  go.opentelemetry.io/collector/config/configtls.(*testLoader).loadClientCAFile()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader_test.go:99 +0x3e
  go.opentelemetry.io/collector/config/configtls.(*clientCAsFileReloader).reload()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader.go:64 +0xa8
  go.opentelemetry.io/collector/config/configtls.(*clientCAsFileReloader).handleWatcherEvents()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader.go:127 +0x3[75](https://github.com/open-telemetry/opentelemetry-collector/actions/runs/6163502394/job/16727198407?pr=8344#step:6:76)
  go.opentelemetry.io/collector/config/configtls.(*clientCAsFileReloader).startWatching.func1()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader.go:96 +0x33

Previous write at 0x00c000012048 by goroutine 14:
  go.opentelemetry.io/collector/config/configtls.(*testLoader).returnErrorOnSubsequentCalls()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader_test.go:103 +0x109
  go.opentelemetry.io/collector/config/configtls.TestErrorRecordedIfFileDeleted()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader_test.go:60 +0xd7
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1648 +0x44

Goroutine 16 (running) created at:
  go.opentelemetry.io/collector/config/configtls.(*clientCAsFileReloader).startWatching()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader.go:96 +0x2c5
  go.opentelemetry.io/collector/config/configtls.TestErrorRecordedIfFileDeleted()
      /home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls/clientcasfilereloader_test.go:55 +0x54
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1595 +0x238
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1648 +0x44

Goroutine 14 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1648 +0x82a
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:2054 +0x84
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1595 +0x238
  testing.runTests()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:2052 +0x896
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.21.1/x64/src/testing/testing.go:1925 +0xb57
  main.main()
      _testmain.go:[79](https://github.com/open-telemetry/opentelemetry-collector/actions/runs/6163502394/job/16727198407?pr=8344#step:6:80) +0x2bd
==================
--- FAIL: TestErrorRecordedIfFileDeleted (0.01s)
    testing.go:1465: race detected during execution of test
FAIL
FAIL	go.opentelemetry.io/collector/config/configtls	0.153s
FAIL
make[2]: *** [../../Makefile.Common:51: test] Error 1
make[1]: *** [Makefile:[123](https://github.com/open-telemetry/opentelemetry-collector/actions/runs/6163502394/job/16727198407?pr=8344#step:6:124): config/configtls] Error 2
make: *** [Makefile:46: gotest] Error 2
make[2]: Leaving directory '/home/runner/work/opentelemetry-collector/opentelemetry-collector/config/configtls'
@djaglowski djaglowski added the bug Something isn't working label Sep 12, 2023
dmitryax pushed a commit that referenced this issue Sep 13, 2023
**Description:**
Data race occurs when the `testLoader.loadClientCAFile()` and
`testLoader.returnErrorOnSubsequentCalls()` are called concurrently.

**Link to tracking Issue:**
fix #8395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant