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(metrics): fix race condition in metrics.Init() #285

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

nvloff-f3
Copy link
Contributor

IterationMetricsEnabled can be concurrently set

==================
WARNING: DATA RACE
Write at 0x00c000124098 by goroutine 12:
  github.com/form3tech-oss/f1/v2/internal/metrics.Init()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20

Previous write at 0x00c000124098 by goroutine 14:
  github.com/form3tech-oss/f1/v2/internal/metrics.Init()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20

Goroutine 12 (running) created at:
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40

Goroutine 14 (finished) created at:
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40

@nvloff-f3 nvloff-f3 requested a review from a team as a code owner September 11, 2024 01:57
@nvloff-f3 nvloff-f3 force-pushed the nvloff-metrics-init-race branch from c5571c9 to df5d113 Compare September 11, 2024 01:58
IterationMetricsEnabled can be concurrently set

```
==================
WARNING: DATA RACE
Write at 0x00c000124098 by goroutine 12:
  github.com/form3tech-oss/f1/v2/internal/metrics.Init()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20

Previous write at 0x00c000124098 by goroutine 14:
  github.com/form3tech-oss/f1/v2/internal/metrics.Init()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics.go:82 +0x7c
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe.func1()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:15 +0x20

Goroutine 12 (running) created at:
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40

Goroutine 14 (finished) created at:
  github.com/form3tech-oss/f1/v2/internal/metrics_test.TestMetrics_Init_IsSafe()
      /Users/nikolayvladimirov/go/src/github.com/form3tech-oss/f1/internal/metrics/metrics_test.go:14 +0xa4
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0x184
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x40
```
@nvloff-f3 nvloff-f3 force-pushed the nvloff-metrics-init-race branch from df5d113 to d2db6af Compare September 11, 2024 02:00
@nvloff-f3 nvloff-f3 merged commit b125e2e into master Sep 11, 2024
4 checks passed
@nvloff-f3 nvloff-f3 deleted the nvloff-metrics-init-race branch September 11, 2024 09:58
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.

2 participants